开发者

Internet Explorer 8 JS Error: 'window.toolbar.visible' is null or not an object

I have the following code for checking when a page within our website is being loaded in a window without toolbars or menubars (there are several other checks, like mobile devices and user agents, but I won't elaborate them here):

if (window.toolbar.visible !== true || window.menubar.visible !== true) {  
    // do some stuff  
}

It works fine everywhere except for Internet Explorer 8 which returns the following error: 'window.toolbar.visible' is null or not an object

(also happens with window.menubar.visible)

I cannot find anywhere an alternative for IE8. Any help on this?

Bonus question: Is there a decent Javascript reference like Mozilla's, but for Internet Explorer?

Thanks for read开发者_如何学Going and thinking about this problem.


IE doesn't have window.toolbar or window.menubar nor do I see any alternatives for them on MSDN's page for the window object.

You can make your check not throw an error by testing for the object before testing for its property, e.g.:

if ((window.toolbar && window.toolbar.visible)
    || (window.menubar && window.menubar.visible)) {  
    // do some stuff  
}

Bonus question: Is there a decent Javascript reference like Mozilla's, but for Internet Explorer?

I think MSDN is the best you're going to do. If you're looking for the source of information on IE's particular brand of JavaScript and DOM objects, there's no better source. It's a pain to navigate, but...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜