Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object Required error

Status
Not open for further replies.

abovetopsecret

Programmer
Jan 16, 2008
61
GB
I have been getting this 'Object Required' error on each page and have found where it is coming from.

Its a script to help make the navigation work in IE i think, and here is the code below:

Code:
activateMenu = function(nav) {

    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById("nav").currentStyle) {  
        var navroot = document.getElementById("nav");
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
                }
            }
        }
    }
}
window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
    activateMenu("nav"); 
    activateMenu("vertnav"); 
}

Can anybody help find that error.

Thanks
 
Ok got it to go away by taking the .currentStyle off the back of line 4.

Didnt seem to have any problems after doing it, so will keep an eye on it, and see if all ok as time goes by.

Thanks
 
You can get JS code to run in IE-only by using the this conditional comment syntax:

Code:
// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
    alert('IE!');
/*@end @*/

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi BillyRayPreachersSon,

Will that code sit on each page that where that piece of JScript is called. As in sit inside the head tags is it?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top