Search code examples
javascriptinternet-exploreractivexwindows-10microsoft-edge

Launching Microsoft Edge browser from a javascript file?


var oIE = new ActiveXObject("InternetExplorer.Application");
var URLname1 = "http://www.google.com";
var URLname2 = "http://www.bing.com";
var navOpenInBackgroundTab = 0x1000;
oIE.Visible = true;
oIE.Navigate2(URLname1);
oIE.Navigate2(URLname2, navOpenInBackgroundTab);

Above is a bit of code in my javascript file (launch.js) that launches Internet Explorer with a specific webpage and then opens a new tab in the same browser window using a 2nd URL.

How do you launch the Microsoft Edge browser instead of IE in Windows 10 using ActiveXObject() or another similar method? I cannot find the InternetExplorer.Application equivalent for Microsoft Edge.


Solution

  • Create an instance of the WSH Shell object instead:

    var oShell = new ActiveXObject("WScript.Shell");
    oShell.Run("cmd.exe /C start microsoft-edge:http://www.microsoft.com");