Categories |
Internet Explorer and version detection
Browser detection is the task when you need to give some special instruction to users using some specific browser. Here I will put the function which allows you to detect browser IE and its version like 5, 6, 7 or 8.
If you just need to detect if the browser is just Internet Explorer (IE). Then following is line which you can put into your code. var IE = navigator.userAgent.indexOf("MSIE") != -1; If the browser is any version of IE, then variable IE stores value true, if not then it store value false. There is one more way to get this thing done. I have seen this many of the developers using it.if(!window.XMLHttpRequest){ var IE = true; }else{ var IE = false; } The above code checks if XMLHttpRequest function is present or not. If it is, then its not IE and if it is not, then its IE. Well what I think that these may also fail in some cases.You can also detect the version of IE using following code. Variable IEv stores version of IE if browser is IE. If the browser is not IE then IEv will store value false. var bd = navigator.appVersion; if(bd.indexOf("MSIE") == -1){ var IEv = false; }else{ var IEv=parseFloat(bd.substring(bd.indexOf("MSIE")+5)); } Category : JavaScript |