Last active
July 8, 2020 10:14
-
-
Save rqx110/6c20380004046b6c37dcc29f4da74560 to your computer and use it in GitHub Desktop.
js提示浏览器不支持
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window._browserIsNotSupported = true; | |
if (window.attachEvent) { | |
window.attachEvent('onload', function() { | |
var lowestSupportedIEVersion = 8; | |
var userAgent = navigator.userAgent.toLowerCase(), | |
s, o = {}; | |
var browser = { | |
version: (userAgent.match(/(?:firefox|opera|safari|chrome|msie)[\/: ]([\d.]+)/))[1], | |
safari: /version.+safari/.test(userAgent), | |
chrome: /chrome/.test(userAgent), | |
firefox: /firefox/.test(userAgent), | |
ie: /msie/.test(userAgent), | |
opera: /opera/.test(userAgent) | |
} /* 获得浏览器的名称及版本信息 */ | |
if (browser.ie && browser.version < 8) { | |
/* 判断是否为IE 6以上版本,是则执行以下操作 */ | |
//document.writeln("<p>您使用的是IE "+browser.version+"<\/p>"); | |
var el = document.createElement('div'), | |
elStyle = el.style, | |
docBody = document.getElementsByTagName('body')[0], | |
linkStyle = 'color:#06F;text-decoration: underline;'; | |
el.innerHTML = '尊敬的用户:<br />' + | |
' 您的浏览器版本过低,使用台风系统需要安装较新版本的浏览器,' + | |
'请<a href="http://windows.microsoft.com/zh-cn/internet-explorer/download-ie" style="' + linkStyle + '" target="_blank">下载安装IE' + lowestSupportedIEVersion + '或更新版本的IE浏览器</a>;' + | |
'也可以在其他浏览器,' + | |
'如<a href="http://www.google.com/intl/zh-CN/chrome/" style="' + linkStyle + '" target="_blank">谷歌Chrome浏览器</a>' + | |
'或<a href="browser-install/360se.exe" style="' + linkStyle + '" target="_blank">360安全浏览器</a>' + | |
'或<a href="browser-install/QQBrowser.exe" style="' + linkStyle + '" target="_blank">QQ浏览器</a>' + | |
'或<a href="browser-install/sogou_explorer.exe" style="' + linkStyle + '" target="_blank">搜狗浏览器</a>' + | |
'或<a href="http://www.firefox.com.cn/download/" style="' + linkStyle + '" target="_blank">Firefox火狐浏览器</a>中打开系统。'; | |
// elStyle.width = '100%'; | |
elStyle.width = '720px'; | |
elStyle.color = '#000'; | |
elStyle.fontSize = '14px'; | |
elStyle.lineHeight = '180%'; | |
elStyle.margin = '60px auto'; | |
elStyle.backgroundColor = '#fffbd5'; | |
elStyle.border = '1px solid #CCC'; | |
elStyle.padding = '24px 48px'; | |
docBody.innerHTML = ''; | |
docBody.appendChild(el); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment