// IE 7, mozilla, safari, opera 9
} else {
// IE6, older browsers
}
This distinguishes between browsers based on the fact that IE 7 knows about the maxHeight css property, whereas previous versions of IE didn’t. Does that seem like a sane approach to you?
Update: over at Ajaxian Arjan points out that it’s a bit simpler to check for window.XmlHttpRequest, which is also new in IE 7.
} else {
// IE6, older browsers
}
This distinguishes between browsers based on the fact that IE 7 knows about the maxHeight css property, whereas previous versions of IE didn’t. Does that seem like a sane approach to you?
Update: over at Ajaxian Arjan points out that it’s a bit simpler to check for window.XmlHttpRequest, which is also new in IE 7.
JAVASCRIPT:
-
-
if (typeof document.body.style.maxHeight != "undefined") {
-
// IE 7, mozilla, safari, opera 9
-
} else {
-
// IE6, older browsers
-
}
You can also use the XHR check: -
if (window.XMLHttpRequest) {
// IE 7, mozilla, safari, opera 9
} else {
// IE6, older browsers
}
If script is executed width , then document.body is not available yet.
if (window.XMLHttpRequest) {
if(document.epando){
alert("ie7");
//IE7
}else{
//mozilla, safari, opera 9…etc
alert("mozilla");
}
} else {
// IE6, older browsers
alert("ie6");
}
偶测试了一下,发现这最后一种方法区别不了 IE7还是firefox,请高人指点一下!