如何解决使用Internet Explorer时始终显示更新通知
我刚刚发现这个handy site可以向用户显示更新浏览器的通知,如果它们已经过时,但是在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)}
解决方法
根据您的描述,看起来用户是否正在使用任何版本的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,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浏览器中的输出:
参考:
How to check the user is using Internet Explorer in JavaScript?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。