Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Detect Internet Explorer
function isIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
var trident = ua.indexOf('Trident/');
return (msie > 0 || trident > 0);
if (isIE()) {
document.getElementById('ie-notice').style.display = 'block';

This comment has been minimized.

Copy link
Owner Author

@danielstgt danielstgt commented Mar 20, 2020


  1. Include the notice for IE users, it will be hidden by default
<div id="ie-notice" style="display:none;">Internet Explorer detected</div>
  1. Include the script (minified version below), which will make the notice visible if a IE user is detected
<script>function isIE(){var e=window.navigator.userAgent,n=e.indexOf("MSIE "),i=e.indexOf("Trident/");return 0<n||0<i}isIE()&&(document.getElementById("ie-notice").style.display="block");</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment