简体   繁体   English

ASP.NET强制用户将IE作为默认值

[英]ASP.NET force user to IE as default

I have a web app built in asp.net/vb. 我有一个内置于asp.net/vb的Web应用程序。 The scripts on the site only work properly with IE. 网站上的脚本仅适用于IE。 Is there a way to force the user to use IE all of the time on the site? 有没有办法强制用户在网站上一直使用IE?

You should not. 你不应该。 Are you really willing to ignore 75% of the traffic? 你真的愿意忽略75%的流量吗? or are you paid by microsoft and have got a really cool website idea? 或者你是由微软支付并且有一个非常酷的网站想法? Any ways, you can do that by using javascript and detecting the browser and if its not IE then do not show anything(Make you main div "display:none" ). 任何方式,你可以通过使用JavaScript和检测浏览器,如果它不是IE,然后不显示任何东西(让你主要div "display:none" )。 Here is an example http://www.w3schools.com/js/js_browser.asp to detect browser. 这是一个用于检测浏览器的示例http://www.w3schools.com/js/js_browser.asp Yet again these approaches are used for customizing styling for browsers and not for what you want it to. 然而,这些方法再次用于为浏览器定制样式,而不是用于您想要的样式。

function detectIE()
{
   var isIE=navigator.userAgent.toString().indexOf("IE") != -1
   if(isIE)
   {
      document.getElementById("main").style.display="block";
   }
   else
   alert("This website can only be accessed using Internet Explorer");
}
<body onload="detectIE">
<div id="main" style="display:none;">
//Everything inside this div
</div>
</body>

Another approach is by using conditionals 另一种方法是使用条件

<!--[if gte IE 6]>
<div id="main" style="display:none;">
    //Everything inside this div
    </div>
<![endif]-->

Remember, it's not a 100% solution, browsers can change there user agent strings and present themselves as IE or javascript can be turned off. 请记住,它不是100%的解决方案,浏览器可以更改用户代理字符串并将其自身呈现为IE或javascript可以关闭。 You should consider adding support for other browsers rather than ignoring them completely. 您应该考虑添加对其他浏览器的支持,而不是完全忽略它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM