Problem with HTML Parser in IE

后端 未结 9 924
醉梦人生
醉梦人生 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: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
    }
    

提交回复
热议问题