9

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.

Andy Piper
  • 11,422
  • 2
  • 26
  • 49
coravacav
  • 131
  • 1
  • 1
  • 7
  • in my case, made the targeting and at the same time a window appeared warning that it was being directed. hints that `microsoft-edge: url` is also used on twitter.com – darkziul Apr 26 '21 at 17:50

3 Answers3

19

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://learn.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>
Molanda
  • 661
  • 1
  • 6
  • 13
5

When I try to visit Twitter in the IE 11 browser it shows below message on the page. It did not redirect to any Microsoft page or it did not launch the Twitter page in the Edge browser.

enter image description here

So I am not sure, how you got this behavior on your machine.

I can see that you want to avoid the popup that asks the user to allow the site to open in the Edge browser.

I did not get any setting that can suppress that popup. I suggest trying to use the JS code that can identify the browser and display a link to open the site in the Edge browser. If the user will click the link then it will not show that the popup and Edge browser will get launched directly.

Sample code:

<!doctype html>
<html>
    <head>
        <script>
            function FindIE() {
  
              var ua = window.navigator.userAgent;
              var msie = ua.indexOf("MSIE ");
  
              if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) 
              {     document.write("The Internet Explorer browser is not supported by this site. We suggest you visit the site using supported browsers." + "<A HREF='microsoft-edge:http://<<Your site address..........>>'>Click here to launch the site in the MS Edge browser</A>");
                  
              }
              else  
              {
                document.write("Welcome...");
              }
  
              return false;
              }
              FindIE()
        </script>
    </head>
    <body>
             
    </body>
</html>

Output in the IE 11 browser:

enter image description here

Further, you can try to modify the code to make it work with the express.js

Deepak-MSFT
  • 10,379
  • 1
  • 12
  • 19
1

While the answers by Molanda and Deepak-MSFT work. Molanda answer will redirect windows 8.1, 2016, 2019 users without edge to a page telling them to use a browser they don't have. Deepak-MSFT requires the user to click a link.

Thanks to navigator.msLaunchUri you can react to support for microsoft-edge. Please note this won't work in Windows 7 if you still care about that.

if (typeof (navigator.msLaunchUri) === "function") {
  navigator.msLaunchUri('microsoft-edge:' + window.location.href,
    function () { window.location.href="https://go.microsoft.com/fwlink/?linkid=2151617" },
    function () {console.log('ie but no edge')}
  )
}
Jeremy Danyow
  • 26,470
  • 12
  • 87
  • 133
bengert
  • 36
  • 3