It\’s so funny how little developers think about it. I don\’t as well, but nowadays I am more aware of these little things that can make your work a nightmare.

Here is a little JS snippet to identify IE11 and a php function as well.

//IE11
navigator.userAgent.match(/Trident\\/7\\./)

// This one is pretty practical.
function GetIEVersion() {
  var sAgent = window.navigator.userAgent;
  var Idx = sAgent.indexOf(\"MSIE\");

  // If IE, return version number.
  if (Idx > 0) 
    return parseInt(sAgent.substring(Idx+ 5, sAgent.indexOf(\".\", Idx)));

  // If IE 11 then look for Updated user agent string.
  else if (!!navigator.userAgent.match(/Trident\\/7\\./)) 
    return 11;

  else
    return 0; //It is not IE
}

if (GetIEVersion() > 0) 
   alert(\"This is IE \" + GetIEVersion());
else 
   alert(\"This is not IE.\");
function get_browser_name($user_agent)
{
	if (strpos($user_agent, \'Opera\') || strpos($user_agent, \'OPR/\')) return \'Opera\';
	elseif (strpos($user_agent, \'Edge\')) return \'Edge\';
	elseif (strpos($user_agent, \'Chrome\')) return \'Chrome\';
	elseif (strpos($user_agent, \'Safari\')) return \'Safari\';
	elseif (strpos($user_agent, \'Firefox\')) return \'Firefox\';
	elseif (strpos($user_agent, \'MSIE\') || strpos($user_agent, \'Trident/7\')) return \'Internet Explorer\';

	return \'Other\';
}

Leave a Comment

Your email address will not be published. Required fields are marked *