SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript not working as include, not sure why?

    Does anyone have an idea as to whey the js does not work on the horizontal drop down menu. I have pretty much used exactly what A List had posted in their article titled, "Drop-down Menus Horizontal Style."

    Any advice?
    Thanks,
    Toby


    <!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>
    <style>
    body {min-width:825px}/* for mozilla and good browsers*/
    </style>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>test.</title>
    <script type="text/javascript">
    startList = function() {
    if (document.all&&document.getElementById) {
    navRoot = document.getElementById("frn_nav");
    for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="LI") {
    node.onmouseover=function() {
    this.className+=" over";
    }
    node.onmouseout=function() {
    this.className=this.className.replace»
    (" over", "");
    }
    }
    }
    }
    }
    window.onload=startList;
    </script>


    <link href="inc/2-COL-SLIDING_III.css" rel="stylesheet" type="text/css" />

    <link href="inc/drop_down_menu.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <cfinclude template="inc/top_nav_left_nav.cfm">
    <div id="frn_nav">
    <ul id="frn_nav">
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a>
    <ul>
    <li><a href="#">History</a></li>
    <li><a href="#">Team</a></li>
    <li><a href="#">Offices</a></li>
    </ul>
    </li>
    <li><a href="#">Services</a>
    <ul>
    <li><a href="#">Web Design</a></li>
    <li><a href="#">Internet
    Marketing</a></li>
    <li><a href="#">Hosting</a></li>
    <li><a href="#">Domain Names</a></li>
    <li><a href="#">Broadband</a></li>
    </ul>
    </li>
    <li><a href="#">Contact Us</a>
    <ul>
    <li><a href="#">United Kingdom</a></li>
    <li><a href="#">France</a></li>
    <li><a href="#">USA</a></li>
    <li><a href="#">Australia</a></li>
    </ul>
    </li>
    </ul>
    </div>
    <cfinclude template="inc/bottom.cfm">
    Last edited by itzaa; Jul 6, 2006 at 15:43. Reason: removed inc js file, pasted js directly. still cannot figure out why js not working in IE.

  2. #2
    SitePoint Enthusiast ada80ro's Avatar
    Join Date
    Apr 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should check if you have other window.onload handlers in your script.
    If you have, only the last one is executed. In this case, if you whish to assign more than one function to be xecuted at onload you should use event listeners:

    Ex:
    //ie
    Code:
    if(window.attachEvent){
    window.attachEvent("onload",startList);
    window.attachEvent("onload",someFunction1);
    window.attachEvent("onload",someFunction2);
    } 
    //w3c
    else if(window.addEventListener){
    window.addEventListener("load",startList,false);
    window.addEventListener("load",someFunction1,false);
    window.addEventListener("load",someFunction2,false);
    }

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    not using any other js, pasted directly in page and still not working.

    I don't have any other JavaScript so that cannot be the problem...unless ColdFusion is generating it and conflicting with the js that I wrote.

    Not sure what else to try.
    any other suggestions?
    thanks

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What's that in the script?

    this.className=this.className.replace»
    (" over", "");


    Seems like a cat ran over the keyboard(?)

    It of course should be:
    Code:
    this.className=this.className.replace(" over", "");
    Saul

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2006
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: what's that in the script

    good eye. I chg'd that but still can't seem to get the drop down menus to work in IE.

    any other suggestions?
    thanks.

  6. #6
    SitePoint Enthusiast ada80ro's Avatar
    Join Date
    Apr 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, you have two identical ids:
    <div id="frn_nav">
    <ul id="frn_nav">
    You should change the div id.


Bookmarks

Posting Permissions

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