IE浏览器提示并跳转google

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> 
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值