Last active
April 17, 2019 07:06
-
-
Save arulprabakaran/f7de0399a44b8842ce4d9c864e68c513 to your computer and use it in GitHub Desktop.
Check for IE browser and allow option to open in Microsoft Edge. Original Source https://github.com/jg-testpage/jg-testpage.github.io
This file contains 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
<!doctype html> | |
<html> | |
<body> | |
<div id="openInEdgeWrapper" style="display: none; background-color: #fc0;"> | |
We've noticed you're running IE11 browser on Windows 10. | |
Did you know you can open this page in Edge browser for a faster and more secure experience? | |
<a id="openInEdge" style="background-color: #0cf">Click here to open in Edge.</a> | |
</div> | |
<script defer> | |
if (document.documentMode === 11 && navigator.userAgent.indexOf('Windows NT 10.0') > -1) { | |
// running IE11 on Windows 10 | |
var openInEdge = document.querySelector('#openInEdge'); | |
openInEdge.href = 'microsoft-edge:' + document.URL; | |
var openInEdgeWrapper = document.querySelector('#openInEdgeWrapper'); | |
openInEdgeWrapper.style.display = 'block'; | |
} | |
</script> | |
<p>This demo page detects IE11 on Windows 10 and shows a banner to open its URL in Edge instead | |
(using microsoft-edge: protocol).<br> | |
It is able to maintain the full URL, including query string parameters.<br> | |
Note though that the demo doesn't work with file: protocol (only with http(s))</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment