首页 > 解决方案 > 使用 Internet Explorer 时始终显示更新通知

问题描述

我刚刚发现这个方便的网站可以向用户显示通知以更新他们的浏览器(如果它们已过时),但在 mi 网站上我需要使用 HTML 5 而 Internet Explorer 不支持它

有谁知道是否可以在使用 Internet Explorer 时始终显示通知但允许在其他浏览器上进行提醒冷却?

到目前为止,我的代码是这样的:

    var $buoop = {required:{e:-4,f:-3,o:-3,s:-1,c:-3},insecure:true,unsupported:true,api:2020.08,text_for_i: {
        'msg':'Tu navegador {brow_name} ya no es soportado.',
        'msgmore': 'Por favor utiliza otro navegador para poder usar nuestro sitio.'
     } };
    function $buo_f(){
     var 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)}

标签: javascripthtmlinternet-explorerupdates

解决方案


根据您的描述,如果用户使用的是任何版本的 IE 浏览器,那么您希望向用户显示使用任何其他浏览器的通知。

我建议您参考下面的示例,这可能会帮助您获得所需的结果。

<!doctype html>
<html>
   <head>
      <script> 
         //detects if user uses Internet Explorer 
         //returns version of IE or false, if browser is not IE 
         //Function to detect IE or not 
         function IEdetection() { 
             var ua = window.navigator.userAgent; 
             var msie = ua.indexOf('MSIE '); 
             if (msie > 0) { 
                 // IE 10 or older, return version number 
                 return ('Tu navegador IE ' + parseInt(ua.substring( 
                   msie + 5, ua.indexOf('.', msie)), 10) + ' ya no es soportado. Por favor utiliza otro navegador para poder usar nuestro sitio.'); 
             } 
             var trident = ua.indexOf('Trident/'); 
             if (trident > 0) { 
                 // IE 11, return version number 
                 var rv = ua.indexOf('rv:'); 
                 return ('Tu navegador IE ' + parseInt(ua.substring( 
                   rv + 3, ua.indexOf('.', rv)), 10) + ' ya no es soportado. Por favor utiliza otro navegador para poder usar nuestro sitio.'); 
             } 
            
             // User uses other browser 
             return ('Welcome...'); 
         } 
         var result = IEdetection(); 
         document.write(result); 
         
         
      </script>
   </head>
   <body>
      <h2>Test page...</h2>
   </body>
</html>

IE浏览器输出:

在此处输入图像描述

参考:

如何检查用户是否在 JavaScript 中使用 Internet Explorer?


推荐阅读