Forum Moderators: open

Message Too Old, No Replies

Detect IE ONLY even when Opera Spoofs?

More IE troubles...

         

JAB Creations

10:41 pm on Jan 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm having issues with IE ... so I need a javascript code that detects IE only. However since Opera (by default even) spoofs as IE and for who knows for WHAT REASON Opera triggers document.all I am uncertain how to create a javascript to detect IE WITHOUT opera.

How in Javascript do I do this...

if useragent = msie (but does not contain opera)
{

}

else {}

JAB Creations

11:18 pm on Jan 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



With a little help from a friend I have figured this out (thanks Undertow) ...

Posted here for those who may need it in the future ... detecting IE but excluding Opera Spoofing as IE...


<html>
<head>
</head>
<body>

<script>
var msie = ((navigator.appVersion.indexOf("MSIE")!= -1)&&!window.opera)? true : false;
if (msie)
{ document.writeln('This IS IE'); }
else
{ document.writeln('This is NOT IE'); }
</script>

</body>
</html>