var innerHTML =
'<style type="text/css">'+
'html,body {height: 100%;}'+
'* {padding: 0;margin: 0;}'+
'#app{display:none;}'+
'.iEshow {width: 100%;height: 100%;background-color: #fff;position: relative;}'+
'.iEshow > div {width: 800px;height: 408px;background-color: #fff;position: absolute;margin: auto; left: 0;right: 0;top: 0;bottom: 60px;border-radius: 10px;}'+
'.iEshow .IEprompt {position: relative;width: 800px;height: 300px;background: url(/IEshow.png) no-repeat;}'+
'.iEshow .IEprompt .title {position:absolute;width:100%;line-height: 45px; font-size:16px; color:#303133;font-weight:300;text-align:left;top:0;font-family: "微软雅黑";}'+
'.iEshow .IEprompt p {position:absolute;width:100%;line-height: 30px; font-size:16px; color:#303133;font-weight:300;text-align:left;bottom:-70px;font-family: "微软雅黑";}'+
'.iEbutton {cursor:pointer;position: absolute;right: 0;bottom: -30px;left: 0;width: 184px;height: 40px;margin: 0 auto;font-size: 14px;color: #fff;background: #0089ff;border: 0;border-radius: 8px;}'+
'.end {position:absolute;width:100%;line-height: 45px; font-size:16px; color:#303133;text-align: right;font-weight:300;bottom:-120px;right:0;font-family: "微软雅黑";}'+
'</style>'+
'<div class="iEshow">' +
'<div>' +
'<div class="IEprompt">' +
'<span class="title">您好!</span>' +
'<p>为保证您的体验流畅和功能正常使用,请切换并使用chrome浏览访问该地址;</p>' +
'</div>' +
'<button class="iEbutton" οnclick="openChrome()">点击使用Chrome打开</button>' +
'<span class="end">谢谢</span>' +
'</div>' +
'</div>'
var userAgent = navigator.userAgent
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 // 判断是否IE<11浏览器 ?
var isEdge = userAgent.indexOf("Edge") > -1 && !isIE // 判断是否IE的Edge浏览器 ?
var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
if (isIE11 || isIE || isEdge) {
document.write(innerHTML)
}
function openChrome() {
try {
var url = window.location.href
var objShell = new ActiveXObject("WScript.Shell")
var cmd = 'cmd.exe /c start chrome.exe "'+ url+'"'
objShell.Run(cmd, 0, true)
} catch (error) {
console.log(error)
}
}
index body
<script type="text/javascript" src="/IEshow.js"></script>