// 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.




JAVASCRIPT:

  1.  
  2. if (typeof document.body.style.maxHeight != "undefined") {
  3.   // IE 7, mozilla, safari, opera 9
  4. } else {
  5.   // IE6, older browsers
  6. }



    You can also use the XHR check:

  7. 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,请高人指点一下!

相关文章:

  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
猜你喜欢
  • 2021-09-30
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-01-03
  • 2021-06-26
相关资源
相似解决方案