0

I need a if(condition) to verify the browser,

if(iBrowser==1)
{
Code for IE}
else {
code for chrome/safari}

will this function works?
is there any iBrowser object in javascript to check for IE Browsers

PraveenKumar S
  • 260
  • 1
  • 13
  • Why browser sniffing? – Ram Dec 29 '15 at 11:02
  • [Related](http://stackoverflow.com/questions/1294586/browser-detection-versus-feature-detection) – James Thorpe Dec 29 '15 at 11:04
  • IE detection in JS... see [this](http://stackoverflow.com/questions/19999388/check-if-user-is-using-ie-with-jquery) – Jeremy Thille Dec 29 '15 at 11:05
  • i am using Ext Js Framework where Ext.isIE is working fine for IE 9 and below, but for IE 11 its not behaving what is Expected. so instead of calling a function and returning some value then putting condition(i.e if(getIEVersion()=="IE11"){}) is there anyway directly checking like iBrowser ==1( verified in IE browser) will it work? – PraveenKumar S Dec 29 '15 at 11:15
  • 1
    That's probably because IE11, contrary to popular belief, is actually fairly standards compliant, [so it fairly drastically changed it's User Agent string](https://msdn.microsoft.com/en-us/library/hh869301(v=vs.85).aspx#ie11) (chiefly the dropping of `MSIE`) so things that would normally be worked around actually work as designed. As mentioned in the first couple of comments, _feature_ detection is a much better approach these days than _browser_ detection. – James Thorpe Dec 29 '15 at 11:16

1 Answers1

0

try this

var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    // Opera 8.0+ 
var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
    // At least Safari 3+
var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // 

Check this link How to detect Safari, Chrome, IE, Firefox and Opera browser?

Community
  • 1
  • 1