Identifying Internet Explorer
Join the Discussion
Attempting to tell which browser is being used based on the information that the browser provides via fields such as the userAgent can be rather extensive since many alternative web browsers can attempt to disguise themselves as Internet Explorer in an attempt to bypass the simpler tests that web novices mistakenly use instead of testing if the required features are supported. There are however two much simpler ways of easily telling clearly whether the browser is Internet Explorer or not in a very few lines of code using a form of feature sensing.
The first way to test if a browser is Internet Explorer or not is to make use of the fact that only Internet Explorer can run VBScript. We can therefore use a combination of code in different languages to set a variable that will identify whether or not the browser is IE.
<script language="vbscript">ie = 1</script>
The only problem with this code is that the latest HTML standards state that the language attribute is deprecated on the script tag and therefore should not be used as the next version of XHTML does not support it. Fortunately Internet Explorer provides an alternative method of producing the same effect that will allow us to avoid this problem.