Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 610
Castaa Avatar asked Dec 17 '25 20:12

Castaa


2 Answers

Windows 10 provides URI schema for lauching Microsoft Egde from any browser. We dont use AcitveXObject at all.

Just include microsoft-edge protocol handler before your URL.

How I resolved it

function openLinkInIE(url){
  window.open("microsoft-edge:"+ url);
}
like image 171
Murtaza Haji Avatar answered Dec 20 '25 13:12

Murtaza Haji


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");
like image 23
securecodeninja Avatar answered Dec 20 '25 12:12

securecodeninja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!