SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: JS Error

  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS Error

    Hi all,

    Can anyone spot the error in my code?? It's causing the IE security menu to display - "Object doesnt support this property or method"

    Thanks,

    Think its to do with this function... function setNav(page,newID

    PHP Code:
    window.onload = function () {
        var 
    document.getElementsByTagName('div');
        for (var 
    i=0;i<x.length;i++)
        {
            if (
    x[i].className == 'dhtml_head')
                
    x[i].onclick clickNav;
        }
        
    closeNav();
        if (
    top.setNav)
            
    setNav(top.setNav,'currentPage');
    }

    function 
    closeNav()
    {
        var 
    document.getElementsByTagName('div');
        for (var 
    i=0;i<x.length;i++)
        {
            if (
    x[i].className == 'dropdown')
                
    x[i].style.display 'none';
        }
    }

    function 
    clickNav(e)
    {
        if (!
    e) var window.event;
        if (
    e.target) var tg e.target;
        else if (
    e.srcElement) var tg e.srcElement;
        while (
    tg.nodeName != 'DIV'// Safari GRRRRRRRRRR
            
    tg tg.parentNode;
        var 
    nextSib tg.nextSibling;
        while (
    nextSib.nodeType != 1)
            
    nextSib nextSib.nextSibling;
        var 
    nextSibStatus = (nextSib.style.display == 'none') ? 'block' 'none';
        
    nextSib.style.display nextSibStatus;
    }

    function 
    setNav(page,newID)
    {
        var 
    test page.indexOf('#')+1;
        if (
    test)
            
    page page.substring(0,test-1);
        var 
    document.getElementsByTagName('a');
        var 
    i;
        for (
    i=0;i<x.length;i++)
        {
            if (
    x[i].href == page)
            {
                
    x[i].id newID;
                break;
            }
        }
        if (
    x.length && newID == 'currentPage')
        {
            var 
    parDiv x[i];
            while (
    parDiv.parentNode.tagName == 'DIV')
            {
                
    parDiv parDiv.parentNode;
                
    parDiv.style.display 'block';
            }
        }

    Last edited by obrienkev; Dec 5, 2006 at 10:52. Reason: forgot to post code!! :)

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the code attached? or am i just not seeing it

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    setNav is being passed incorrect arguments here:
    Code:
     if (top.setNav)
            setNav(top.setNav,'currentPage');

  4. #4
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what should be passed? thanks.

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From your code it appears that setNav expects two strings, but you are passing a function reference as the first argument.

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure what I should change. below is my html code. I am grateful for any help. thanks.

    PHP Code:
     <div class="dhtml_head">
         <
    h2 class="drop">Fund Accounting</h2>
     </
    div>  
     
     <
    div class="dropdown"> <!-- Dropdown Div -->
    ...
     </
    div> <!-- end dropdown div --> 

  7. #7
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not 100&#37; sure, but...
    Instead of this:
    Code:
        if (top.setNav)
            setNav(top.setNav,'currentPage');
    Try this:
    Code:
            setNav(window.location.href, 'currentPage');

  8. #8
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that seems to do the job!! thanks!!


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
  •