www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Problem with my js code for a menu.

  1. #1
    Join Date
    Feb 2009
    Posts
    6

    resolved [RESOLVED] Problem with my js code for a menu.

    Hi all,

    I am having real trouble with my code not working.

    I have an external file menu.js containing the following code:
    Code:
    function writeText() {
    var txt = "<h3 align="center">Menu</h3>
    <p align="left">
    <strong>&nbsp; Series Stories</strong><br />
    <li2>&nbsp; <a href="contact.html">Contact Me</a></li2><br />
    "
    document.getElementById("myDiv").innerHTML = txt;
    }
    My html page index.html is thus :
    Code:
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Web Site Title</title>
    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1" />
    <meta name="Robots" content="NOINDEX" /> <!-- maybe remove -->
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <script type="text/javascript" src="menu.js"></script>
    <link rel="stylesheet" type="text/css" href="daveo.css" />
    <link rel="stylesheet" type="text/css" href="2c-lc-static-presentation.css" />
    </head>
    <body onload = "writeText()">
    <!-- left column -->
    <div id="lh-col"><br />
    <!-- MENU CODE START -->
    <p><div id = "myDiv"></div></p>
    <!-- END OF MENU CODE -->
    </div>
    <!-- end of left column -->
    <!-- right column -->
    <div id="rh-col">
    <h3 align="center">HEading</h3> <!-- Website Title -->
    <div align="center" style="color:Black;">
    Home Page
    </div> <!-- Story/Page Title -->
    <p>Blah Blah.</p>
    <p>Blah Blah <img src="img/quill_blue.jpg" alt="Always Writing" class="float-right" width="100" height="75"/> North, I Blahh
    <p>
    <p>
    Blah Blah Blah</p>
    <p>
    <strong>Please come back and see what's new.</strong>
    </p>
    <p>Site updates:<br />
    Blah blah
    </p>
    
    
    </div>
    <!-- end of right column -->
    
    </body>
    </html>
    I have two other .css files that load the page up (can paste the code if required).

    The pages loads up with everything except the menu section.

    Any ideas?

    Thanks in advance.

  2. #2
    Join Date
    Jul 2011
    Posts
    127
    May be your issue is here:
    Code:
    var txt = "<h3 align="center">Menu</h3>
        <p align="left">
        <strong>&nbsp; Series Stories</strong><br />
        <li2>&nbsp; <a href="contact.html">Contact Me</a></li2><br />"
    In this code there are only double quotes. This code will produce errors in JavaScript.
    Try this:
    Code:
    var txt = "<h3 align='center'>Menu</h3>
        <p align='left'>
        <strong>&nbsp; Series Stories</strong><br />
        <li2>&nbsp; <a href='contact.html'>Contact Me</a></li2><br />";

  3. #3
    Join Date
    Feb 2009
    Posts
    6
    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles