What is the best way to identify IE 11 browser?
The format of the UA for IE 11 is : Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko
I'm using the following code but I need to know if it is perfectly safe to use or is there any alternate approach too?
sUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
comstart = instr(sUserAgent,"(")
comend = instr(sUserAgent,")")
if comstart <> 0 then
cmtlist = mid(sUserAgent,comstart+1,comend-comstart-1)
else
cmtlist = " ; ; ;"
end if
cmtArray = split(cmtlist,";")
if instr(sUserAgent,"rv") > 0 then ' it's a Microsoft browser
browserName="MSIE"
browserVersion=right(cmtArray(1),len(cmtArray(1))-5)
endif
Also in some other file I'm using the following JavaScript code. Please advice if using this code is advisable or not. If there is a better approach , please suggest. Can this code give some unexpected results in the future? :
// In IE11, the true version is after "rv" in the User Agent string
var nAgt = navigator.userAgent;
if ((verOffset = nAgt.indexOf("rv")) != -1)
{
browserName = "Microsoft Internet Explorer";
fullVersion = nAgt.substring(verOffset + 3);
}