如何允许Web应用程序仅在IE浏览器中运行?

如何允许Web应用程序仅在IE浏览器中运行?

问题描述:

我想只允许在IE浏览器中使用网页应用。选择Chrome后,应用程序将在警报脚本后退出。但是在IE 11中会出现警报消息。它适用于较低版本的IE浏览器。



我的代码如下:

< script language =javascripttype = 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应用程序仅在IE和Mozilla中运行);

window.open('','_ self','');

window.close();

}

}

< / script>

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>

IE11在UserAgent中有变化字符串 - 不再总是有一个MSIE签名...

在这里阅读:

用户字符串更改(Windows) [ ^ ]

了解用户代理字符串(Internet Explorer) [ ^ ]
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)[^]