Web Analytics Made Easy -
StatCounter help with menu - CodingForum

Announcement

Collapse
No announcement yet.

help with menu

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help with menu

    I have a JavaScript function as follows for a menu with a hidden dropdown:

    Code:
    var timeout = 5;
    var closetimer = 0;
    var menuitem = 0;
    var browser = navigator.appName;
    
    
    function test(){
    
    
    }
    
    function mopen(id){
    
    
    
    
    
    
    
    }
    
    function mclose(){
    
    }
    
    function closetime(){
    
    }
    
    function cancelclosetime(){
    
    
    
    
    }
    
    document.onclick = mclose;
    
    
    
    
    I want to "call" into this html a JavaScipt function that will print the menu, so if there are edits to be done to the menu in the future, they can easily be done globally on all pages on the site by editing the single file.
    But this doesn't seem to be working -- my knowledge of JavaScript is very limited, not sure if I'm making a small quote error or just entirely off….
    
    
    document.write('<div id="siteNav">')
    document.write("<ul>")
    document.write("<li>")
    document.write('<a onmouseover="mopen(\'m1\')" onmouseout="closetime()">')
    document.write("<b>Some<\/b>")
    document.write(<"\/a>")
    document.write('<div id="m1" onmouseover="cancelclosetime()" onmouseout="closetime()">')
    document.write('<a href="./Some2.html">Topic of Some Page 2<\/a>')
    document.write('<a href="./Some3.html">Topic of Some Page 3<\/a>')
    document.write('<a href="./Some4.html">Topic of Some Page 4<\/a>')
    document.write('<a href="./Some5.html">Topic of Some Page 5<\/a>')
    document.write('<a href="./Some6.html">Topic of Some Page 6<\/a>')
    document.write('<a href="./Some7.html">Topic of Some Page 7<\/a>')
    document.write('<a href="./Some8.html">Topic of Some Page 8<\/a>')
    document.write("<\/li>")
    document.write("<\/ul>")
    document.write("<\/div>")
    Last edited by oracleguy; Apr 2, 2009, 05:40 PM. Reason: Please use code tags

  • #2
    this works in FF. I didn't open it with IE yet. Yep, it open and makes a menu
    If you don't like the vertical layout, remove the <br> tags and maybe put in &nbsp; instead so you get a non-breaking space
    Code:
    <script>
    var timeout = 5;
    var closetimer = 0;
    var menuitem = 0;
    var browser = navigator.appName;
    
    
    function test(){
    
    
    }
    
    function mopen(id){
    
    
    
    
    
    
    
    }
    
    function mclose(){
    
    }
    
    function closetime(){
    
    }
    
    function cancelclosetime(){
    
    
    
    
    }
    
    document.onclick = mclose;
    
    
    
    
    document.write('<div id="siteNav">')
    document.write('<ul>')
    document.write('<li>')
    document.write('<a onmouseover="mopen(m1)" onmouseout="closetime()">')
    document.write('<b>Some</b>')
    document.write('</a>')
    document.write('<div id="m1" onmouseover="cancelclosetime()" onmouseout="closetime()">')
    document.write('<a href="./Some2.html">Topic of Some Page 2</a><br>')
    document.write('<a href="./Some3.html">Topic of Some Page 3</a><br>')
    document.write('<a href="./Some4.html">Topic of Some Page 4</a><br>')
    document.write('<a href="./Some5.html">Topic of Some Page 5</a><br>')
    document.write('<a href="./Some6.html">Topic of Some Page 6</a><br>')
    document.write('<a href="./Some7.html">Topic of Some Page 7</a><br>')
    document.write('<a href="./Some8.html">Topic of Some Page 8</a><br>')
    document.write('</li>')
    document.write('</ul>')
    document.write('</div>') 
    </script>

    Comment


    • #3
      this probably better to use
      Code:
      <script>
      
      
      
      
      function load(){
      
      
      
      var menu=document.getElementById("menu");
      menu.innerHTML+="<div id='siteNav'>";
      menu.innerHTML+="<ul>";
      menu.innerHTML+="<li>";
      menu.innerHTML+="<a  href='#'>";
      menu.innerHTML+="<b>Some</b>";
      menu.innerHTML+="</a>";
      menu.innerHTML+="<div id='m1'  >";
      menu.innerHTML+="<a href='./Some2.html'>Topic of Some Page 2</a><br>";
      menu.innerHTML+="<a href='./Some3.html'>Topic of Some Page 3</a><br>";
      menu.innerHTML+="<a href='./Some4.html'>Topic of Some Page 4</a><br>";
      menu.innerHTML+="<a href='./Some5.html'>Topic of Some Page 5</a><br>";
      menu.innerHTML+="<a href='./Some6.html'>Topic of Some Page 6</a><br>";
      menu.innerHTML+="<a href='./Some7.html'>Topic of Some Page 7</a><br>";
      menu.innerHTML+="<a href='./Some8.html'>Topic of Some Page 8</a><br>";
      menu.innerHTML+="</li>";
      menu.innerHTML+="</ul>";
      menu.innerHTML+="</div>"; 
      }
      
      </script>
      <body onload="load()">
      <div id="menu"></div>

      Comment

      Working...
      X