IE version detection in Javascript

Detection of theĀ  newer versions of IE is much more messy than before. Since IE uses the Trident rendering engine, each IE version uses a particular Trident version, which is what the sample script below does.


	function showInfo() {
		var nav= (navigator.userAgent);
		if (nav.indexOf("Trident/7.0") > -1) {
			alert("IE 11.0");
		else if (nav.indexOf("Trident/6.0") > -1) {
			alert("IE 10.0");
		else if (nav.indexOf("Trident/5.0") > -1) {
			alert("IE 9.0");
		else if (nav.indexOf("Trident/4.0") > -1) {
			alert("IE 8.0");
			alert("IE is older than 8.0");

	<a href="#" onclick="showInfo();">Show Info</a>

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.