简体   繁体   中英

Unable to get property 'visibility' of undefined or null reference

i changed our site from HTML to HTML5. Now i have issues with our menu that gives below error:

Unable to get property 'visibility' of undefined or null reference

any idea, how to solve it ?

function hidectxmenu()
{
    if(menu_shadow.style.visibility)
    menu_shadow.style.visibility = "hidden";
    if (menuobj.iefiltercapable)  
    if (menuobj.filters[0]) menuobj.filters[1].Apply();
    if(menuobj.style.visibility) 
    menuobj.style.visibility ="hidden";
    if (menuobj.iefiltercapable)  
    if (menuobj.filters[0]) menuobj.filters[1].Play();
    menuobj.style.display = 'none';
}

Looks like menu_shadow is undefined. Check where you defined it. Double check spelling.

Also, the element.style.visibility returns a string so if probably want to add a check against that string to return a boolean for your if condition. You probably want to add === "visible" to the end of what you have.

Also, to make your code more readable for yourself, and for me, indent for each if so we can tell at a glance where control flow is going, and use {} 's on your if blocks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM