如何允许Web应用程序仅在IE浏览器中运行? [英] How to allow web application to run only in IE Browser?

查看:248
本文介绍了如何允许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)[^]


这篇关于如何允许Web应用程序仅在IE浏览器中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆