Wor*_*ork 49 javascript php jquery internet-explorer
我不想让用户使用Microsoft Internetexplorer(任何版本)访问我的网站.
到目前为止我发现的是检测它是否低于或等于10版本.
一个非常令人讨厌的事情:Internetexplorer> v10不承认自己是一名InternetExplorer.
到目前为止我发现并尝试过的内容:
if(navigator.appVersion.indexOf("MSIE")!=-1){
alert("You use IE. That´s no good.");
}
Run Code Online (Sandbox Code Playgroud)
要么
if ( $.browser.msie ) {
alert( $.browser.version );
}
Run Code Online (Sandbox Code Playgroud)
和
http://msdn.microsoft.com/en-us/library/ie/ms537509%28v=vs.85%29.aspx
如果有javascript,jquery或php,我会使用任何解决方案.
Top*_*ons 85
这对我来说可以检测任何版本的IE 5-11(Internet Explorer)(2014年8月5日):
if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
{
alert("Please dont use IE.");
}
Run Code Online (Sandbox Code Playgroud)
Sar*_*nga 27
这是因为Internet Explorer的每个版本都会更新用户代理字符串.
MSIE在Internet Explorer 11中删除了令牌并$.browser用于navigator.userAgent确定平台,并在jQuery 1.9中将其删除.
您可以使用以下代码来确定具有纯java脚本的浏览器.
var isIE = !!navigator.userAgent.match(/Trident/g) || !!navigator.userAgent.match(/MSIE/g);
if(isIE){
alert("IE");
}
else{
alert("Not IE");
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
如果你不是因为用户目前使用的版本,你可以尝试使用它来检测浏览器是否支持 Conditional Compilation Statements
http://msdn.microsoft.com/en-us/library/7kx09ct1%28v=vs.80%29.aspx
if(/*@cc_on!@*/false)
{
// You use IE. That´s no good.
alert("oh my god");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
70352 次 |
| 最近记录: |