Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I want to allow web app only in IE Browser. On selecting Chrome the Application will exit after the alert script. But in IE 11 the alert message comes. It works for the lower version IE Browsers.

My code is as below:
<script language="javascript" type="text/javascript">


window.onload = function() {
var nAgt = navigator.userAgent;
alert(nAgt.indexOf("MSIE"));
alert(nAgt.indexOf("Firefox"));
if ((verOffset = nAgt.indexOf("MSIE")) == -1 && (verOffset = nAgt.indexOf("Firefox")) == -1) {
alert("This application runs only in IE and Mozilla");
window.open('', '_self', '');
window.close();
}
}
</script>
Posted
Comments
Philippe Mori 5-Jan-16 19:49pm    
Internet Explorer is an obsolete browser. Forget about it!

1 solution

IE11 has changes in UserAgent string - not always there is a MSIE signature in it anymore...
Read here:
User-agent string changes (Windows)[^]
Understanding user-agent strings (Internet Explorer)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900