Quick Javascript Check for IE

Actually this wouldn’t be a big thing or anything, but there is one little thing that one needs to be aware of – OPERA! Opera can disguise itself as IE and that way pending on the user it can easily happen that in browserchecks the user get’s sent the wrong way.

As mentioned above, this is quick an dirty, for real detection the script nees to be far longer and quite frankly one should only resort to a browser check if one can absolutely NOT solve the problem another way, as there is always a chance that a browser or specific browser version get’s sent the wrong way or not sent anywhere at all.

So here is the code:

document.write("User Agent Name:
");

if (navigator.userAgent.indexOf('Opera') != -1) {
document.write("Opera");
}
else {
document.write(navigator.appName);
}

document.write("

Reiner IE Check:
");
if ((document.all) && (navigator.userAgent.indexOf('Opera')== -1))
{
document.write("IE");
} else {
document.write("not IE");
}

You can now modify it to your needs to switch whatever you need to.