Skip to content

Instantly share code, notes, and snippets.

@Graham42
Last active December 16, 2017 22:35
Show Gist options
  • Save Graham42/b9db763d595455ed3650da9ac7deb63d to your computer and use it in GitHub Desktop.
Save Graham42/b9db763d595455ed3650da9ac7deb63d to your computer and use it in GitHub Desktop.
refuse to serve IE - this is conditionally useful
<body>
<noscript>
<p>You need to enable JavaScript to run this app.</p>
</noscript>
<!-- Check for IE 9 and below -->
<!--[if IE]>
<p>Sorry! Your browser is not supported. We recommend using
<a href="https://www.google.com/chrome/browser/">Chrome</a> or
<a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>.
</p>
<![endif]-->
<!-- Check for unsupported browsers that are not IE 9 and below -->
<!--[if !IE]><!-->
<script type="text/javascript">
(function () {
// This is an estimate, pretty much all modern browsers support promises
var supported =
window.Promise !== undefined &&
window.Promise !== null &&
Object.prototype.toString.call(window.Promise.resolve()) === '[object Promise]';
if (!supported) {
var root = document.getElementById('root');
root.id = 'x';
root.innerHTML =
'<p>Sorry! Your browser is not supported. We recommend using <a href="https://www.google.com/chrome/browser/">Chrome</a> or <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a>.</p>';
}
})();
</script>
<!--<![endif]-->
</body>
@Graham42
Copy link
Author

Graham42 commented Nov 30, 2017

This should not be used for websites. Websites should gracefully degrade.

However, for web apps this may be reasonable depending on your business case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment