Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect from Internet Explorer to Microsoft Edge seamlessly?

I'm trying to deprecate Internet Explorer on my website, and I would like to replicate Twitter's behavior when someone tries to visit the site on Internet Explorer.

From what I've pieced together of their process so far it seems like there is a server side check based on the User Agent string that detects the browser type, then sends something to redirect to https://go.microsoft.com/fwlink/?linkid=2135547 but simultaneously opens up Microsoft Edge and directs that to https://twitter.com

The confusing part for me is how they manage to open Microsoft Edge without opening a dialog box that asks whether you would like to open the link with the application. I've seen websites use microsoft-edge:url to open an url in Microsoft Edge but that always asks you whether you'd like to open that application or not.

If anyone has information on how they manage it or how to replicate it, it'd be appreciated.

In case it helps, my website is built on express.js, and the redirecting I'm trying is based on res.redirect in some express middleware.

like image 285
coravacav Avatar asked Aug 13 '20 23:08

coravacav


People also ask

Why does Microsoft Edge open when I click on Internet Explorer?

in the internet Explorer compatibility setting, you will see an option "Let Internet Explorer open sites in Microsoft Edge" , the default value is Incompatible Sites only(Recommended). You can change it to Never.


1 Answers

This appears to be a special interface between Internet Explorer and Edge that uses an Internet Explorer Browser Helper Object named “IEtoEdge BHO” along with a list of incompatible websites that is maintained by Microsoft.

This requires Microsoft Edge Stable version 87 or later.

https://docs.microsoft.com/en-us/deployedge/edge-learnmore-neededge

The following code closely resembles the behavior, with the exception of the dialog in Edge to migrate the browsing data and preferences. I don't receive any prompt, so perhaps that has changed.

<script>
  if(/MSIE \d|Trident.*rv:/.test(navigator.userAgent)) {
    window.location = 'microsoft-edge:' + window.location;
    setTimeout(function() {
      window.location = 'https://go.microsoft.com/fwlink/?linkid=2135547';
    }, 1);
  }
</script>
like image 171
Molanda Avatar answered Nov 10 '22 19:11

Molanda