Problem with HTML Parser in IE

后端 未结 9 834
醉梦人生
醉梦人生 2020-12-24 05:56

I am trying to create a dialog box that will appear only if the browser selected is IE (any version) however I get this error:

Message: HTML Parsing E

相关标签:
9条回答
  • 2020-12-24 06:39

    The best way to address IE only are conditional comments. You don't even need to use JavaScript. See for example http://www.positioniseverything.net/articles/ie7-dehacker.html.

    0 讨论(0)
  • 2020-12-24 06:39

    A current version of https://apis.google.com/js/plusone.js caused this bug on IE8 in one of my sites.

    Easiest solution - remove google+.

    Easy solution - wrap the code in jquery's document.ready -function or similar:

    $(document).ready(function(){
         var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
         po.src = 'https://apis.google.com/js/plusone.js';
         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    });
    
    0 讨论(0)
  • 2020-12-24 06:41

    Browser sniffing is a kludge that should be avoided when possible. It's best to sniff for the capability you want to use. Say you want to execute an XPath expression using document.evaluate(), but you don't know whether it's supported. Instead of sniffing for supported browsers, do this:

    if (document.evaluate) {
        // go ahead and use it
    } else {
        // browser doesn't support it; do something else
    }
    
    0 讨论(0)
提交回复
热议问题