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
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.
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);
});
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
}