Skip to content

Instantly share code, notes, and snippets.

@lihe6666
Last active July 20, 2020 09:15
Show Gist options
  • Select an option

  • Save lihe6666/5b157520d3a1c6a8aafb51a8ea5828fd to your computer and use it in GitHub Desktop.

Select an option

Save lihe6666/5b157520d3a1c6a8aafb51a8ea5828fd to your computer and use it in GitHub Desktop.
[checkIEVersion] Check is ie browser version. #check #javascript
(function() {
setTimeout(function() {
var div = document.createElement('div');
div.id = 'js_ie_notsupport';
div.innerHTML='<div class="ie-not-support">将浏览器更新为Firefox浏览器或Chrome浏览器,以获得更好的体验</div>'
if (window.attachEvent) {
window.attachEvent('onload', checkIEVersion);
} else if (window.addEventListener) {
window.addEventListener('load', checkIEVersion, false);
}
function checkIEVersion() {
var ua = navigator.userAgent;
if ((ua.indexOf('compatible') !== -1) && (ua.indexOf('MSIE') !== -1)) {
if (ua.indexOf('rv') === -1) {
document.body.appendChild(div);
}
}
}
}, 0)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment