Created
June 25, 2021 15:05
-
-
Save joshuafredrickson/c6d502781884f8655a9ce22b2653a9a8 to your computer and use it in GitHub Desktop.
Redirect IE11 to Edge automatically
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
/** | |
* Detect IE11 and open the current window in Edge instead | |
*/ | |
if ( | |
navigator.userAgent.indexOf('MSIE') !== -1 || | |
navigator.appVersion.indexOf('Trident/') > -1 | |
) { | |
// Redirect to Edge | |
window.location = 'microsoft-edge:' + window.location.href; | |
// Close the current window | |
setTimeout(function () { | |
window.open('', '_self', '').close(); | |
}, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using the
microsoft-edge:
protocol in IE11 will open the link in Edge automatically, essentially forcing the user to view the site in Edge if it's installed. This could concept could be fleshed out into a modal window with link instead depending on the site's needs.