Scheme | Detects | ||||||||
---|---|---|---|---|---|---|---|---|---|
document.getElementById | Firefox1+, IE5+, Opera7+, Safari, and most modern browsers in general. | ||||||||
window.getComputedStyle | Firefox1+ and Opera 8+, and Safari 2+ | ||||||||
window.globalStorage | Firefox2+ | ||||||||
window.globalStorage && window.postMessage | Firefox3+ | ||||||||
document.getElementsByClassName | Firefox3+ and Opera 9.5+, and Safari 3+ | ||||||||
document.querySelector | Firefox3.5+, IE8+ (in standards compliant mode only), Opera9.5+, and Safari 3+ | ||||||||
document.all | IE4+ | ||||||||
window.attachEvent | IE5+ | ||||||||
window.createPopup | IE5.5+ | ||||||||
document.compatMode && document.all | IE6+ | ||||||||
window.XMLHttpRequest | IE7+, Firefox1+, and Opera8+ | ||||||||
window.XMLHttpRequest && document.all or: document.documentElement && typeof document.documentElement.style.maxHeight!="undefined" |
IE7+ Note: First scheme will fail if visitor explicitly disables native xmlHTTPRequest support (under Toolbar-> Internet Options-> Advanced). The second one will not. |
||||||||
XDomainRequest | IE8+ | ||||||||
document.documentMode | IE8+ (detects IE8 in a specific document mode,
such as standards complaint). Because IE8 can render a page in various
different modes depending on the page's doctype plus the presence of
certain HTML elements,
This means that even though the user is using IE8 or IE9, for
example, if a webpage is missing a
valid doctype,
|
||||||||
XDomainRequest && window.msPerformance | IE9+
|
||||||||
window.opera | Opera (any version) |
* Since Opera by default also identifies itself as IE (apart from Opera), with support for many of IE's proprietary objects, the IE detection schemes above will also return true for Opera. Use "window.opera" in combination to filter out Opera browsers.
if (document.documentElement && typeof document.documentElement.style.maxHeight!="undefined") alert("You're using IE7")
The following detects a page using IE8 standards compliant mode:
if (document.documentMode==8) alert("IE8 standards mode")
No comments:
Post a Comment