I have a lab management webapp that lists servers on my network. With a click in IE I can open a terminal services session to that server.

The code - shown below - works in IE, but not in chrome or firefox. Can anyone suggest how I can make this work in Chrome (Firefox would be nice too, but Chrome is more important.)

I fooled around with an idea to do it with jquery, but couldn't make it work. I do have jquery loaded, though.

<span style="color:blue;cursor:hand;" onClick="runApp('mstsc /v 10.1.2.3'); return false;" title="Click to open Terminal Services session">HOSTNAME</span>

Would appreciate any advice. This has crippled an otherwise very useful tool.

Dani AI

Generated

Short diagnosis and where the problem lives

What works in IE is not magic in your HTML — it’s IE-only host integration (ActiveX / WScript) that can spawn local programs. Code that uses WScript.Shell or an ActiveX helper will run inside IE when security settings permit, but Chrome and Firefox don’t expose that COM/ActiveX mechanism to page scripts for security reasons. (rgagnon.com)

Why the jQuery fixes from won’t change that

Event wiring (.click() vs .on()) only affects whether the click handler runs. If runApp() uses IE-only ActiveX to call mstsc, wiring the click properly will still not let Chrome/Firefox launch a local executable — those browsers deliberately block that capability. Use the event fixes for UI behavior, but treat the launcher itself as the cross‑browser problem. (developer.mozilla.org)

Practical, reliable alternatives

  • Fast + low-friction: have the server generate an .rdp file (set full address:s:10.1.2.3 in the file) and send it as an attachment. Modern browsers will download it and the OS can open it with the Remote Desktop client (users can opt to always open that file type). This is what RD Web / web client flows do. (learn.microsoft.com)

  • One-click native launch: register a custom URI protocol on Windows (installed once by an admin/installer) that your link calls (e.g. myrdp://10.1.2.3). The registry entry points to a small native launcher which strips the scheme and invokes mstsc /v:host. Example registry shape (launcher must parse the %1 argument):

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\myrdp]
    @="URL:MyRDP Protocol"
    "URL Protocol"=""
    
    [HKEY_CLASSES_ROOT\myrdp\shell\open\command]
    @="\"C:\\Program Files\\MyRdpLauncher\\myrdplauncher.exe\" \"%1\""

    See Microsoft guidance on registering URI handlers and the Remote Desktop URI schemes for current client support. (gist.github.com)

Workarounds and testing tips

If keeping the existing IE behavior is required inside Chrome, an IE‑engine helper (IE Tab) will run the page under IE and let the old runApp() work — useful for intranet tooling only. For debugging, replace runApp(...) temporarily with a link to a generated .rdp or a test ms-rd: URI (where supported) to observe how Chrome/Firefox hand off to the OS. Security note: any solution that launches local executables from a web page should be deployed only in trusted intranet environments and done via installer/registry, not via arbitrary client-side script. (chromewebstore.google.com)

Summary: ’s IE code is expected to fail in Chrome/Firefox. Move to a download‑or‑URI approach (server .rdp or registered protocol + small launcher) or keep using an IE engine shim if immediate backward compatibility is required.

Recommended Answers

All 3 Replies

Member Avatar for Member #949455

The code - shown below - works in IE, but not in chrome or firefox. Can anyone suggest how I can make this work in Chrome (Firefox would be nice too, but Chrome is more important.)

Can you post your code regarding with runApp() function.

The runApp() code is in my original post above.

The alternative I've been looking at is a jquery setup where the HTML code is:

<span class="tsconnect" device_ip="10.1.2.3" style="color:blue;cursor:hand;" title="Click to open a Terminal Services session">[LBPDMPKW01]</span>

and the javascript code is;

$(document).ready(function() {
  $(".tsconnect").click(function () {
    alert("hello");
    //  runApp($(this).data("device_ip"));
    //  alert($(this).data("device_ip"));
    //  runApp("ping -t 127.0.0.1");
    //  runApp("mstsc /v 10.1.2.3"); return false;
    //  runApp("c:\temp\temp.cmd"); return false;
  });
}); 

I can't get any of the commented runapp() or alert() lines to run, though I know the function is firing because the uncommented alert("hello"); line works whenever I click on the spanned text.

Member Avatar for Member #949455

I can't get any of the commented runapp() or alert() lines to run, though I know the function is firing because the uncommented alert("hello"); line works whenever I click on the spanned text

Instead of click()

$(".tsconnect").click(function () 

Try using on() function:

$(document).ready(function() {
$("tsconnect").on("click",function(){
alert("hello");
runApp($(this).data("device_ip"));
alert($(this).data("device_ip"));
runApp("ping -t 127.0.0.1");
runApp("mstsc /v 10.1.2.3"); return false;
runApp("c:\temp\temp.cmd"); return false;
});
}); 

I'm not sure it's gonna work because this doesn't look right inside of runApp() & alert():

$(this).data("device_ip")
ping -t 127.0.0.1
mstsc /v 10.1.2.3
c:\temp\temp.cmd

Try to put 3 alerts and see how it goes. Put like one word in each alert.
If all 3 alerts appear then there's something wrong with

$(this).data("device_ip")
ping -t 127.0.0.1
mstsc /v 10.1.2.3
c:\temp\temp.cmd

So there's nothing wrong with the function runApp() & alert()

You need to find another way to make it readable so that runApp() & alert() function can read it and work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.