首页 > 解决方案 > 如何仅在 Internet Explorer 中加载网站而不在其他浏览器上打开

问题描述

我希望我的 php 网站仅在 internet-explorer 上打开,而它不应该在其他浏览器上打开,并且还向他们显示消息以在 internet-explorer 上查看网站

我在下面尝试过这段代码,但它只显示更新浏览器的消息

               <script> 
            var $buoop = {required: 
   {e:-4,f:-3,o:-3,s:-1,c:-3},insecure:true,api:2019.10 }; 
    function $buo_f(){ 
     v    ar e = document.createElement("script"); 
    e.src = "//browser-update.org/update.min.js"; 
    document.body.appendChild(e);
     };
    try {document.addEventListener("DOMContentLoaded", 
    $buo_f,false)}
     catch(e){window.attachEvent("onload", $buo_f)}
      </script>

标签: phphtmlcodeigniterinternet-explorerbrowser

解决方案


如果你想通过 JS 来做这件事而不是试试这个..

if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) //IF IE > 10
    {
        alert('EI');
    }else{
        alert('noooooo');
    }

推荐阅读