Przeszukaj pomoc

Unikaj oszustw związanych z pomocą.Nigdy nie będziemy prosić Cię o dzwonienie na numer telefonu, wysyłanie SMS-ów ani o udostępnianie danych osobowych. Zgłoś podejrzaną aktywność, korzystając z opcji „Zgłoś nadużycie”.

Learn More

How can I craft a link to work in other browsers when clicked in Firefox?

  • 14 odpowiedzi
  • 1 osoba ma ten problem
  • 295 wyświetleń
  • Ostatnia odpowiedź od kjstech

more options

We have Firefox ESR deployed in our Enterprise. Our core financial banking system runs on Firefox. Our Intranet page has special javascript code to take advantage of IE's ActiveX so if one were to launch IE, the default page (our intranet) has an icon to our core banking system and if clicked the script uses ActiveX and runs this code: ar oShell = new ActiveXObject("Shell.Application"); var commandtoRun = "C:\\Program Files\\Mozilla Firefox\\firefox.exe" ; oShell.ShellExecute(commandtoRun,"https:/path-to-core-system-web-ui","","open","1"); }

So when they click on the icon which is basically an img with the style of cursor: pointer; it does an onclick launch to that code which launches firefox to the web command. If you open our Intranet page in Firefox or Chrome then ActiveX does not run so it just launches in a new tab the link to our core system.

This week (1/19) we are going live with a new loan origination system. The LoS system vendor claims they want us to use Chrome for their system. Well a few months ago we changed the default browser to Firefox with GPO's and now the issue is our Intranet page opens in Firefox (which works great) as any other, but how can we craft our link to open the Loan Origination System in Chrome? I call B.S. that is only works in Chrome. It seems to work in Firefox to me, but that's all they want to support so if we need help they won't help us unless we are using it in Chrome. I know I'm not happy about it either. I'm just happy to be rid of IE finally. I like Firefox (and Chrome) but if I can do any tricks to craft a link, maybe a javascript function to launch something like commandtoRun = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", along with the argument with the LoS web URL, that would be great.

Thanks!

We have Firefox ESR deployed in our Enterprise. Our core financial banking system runs on Firefox. Our Intranet page has special javascript code to take advantage of IE's ActiveX so if one were to launch IE, the default page (our intranet) has an icon to our core banking system and if clicked the script uses ActiveX and runs this code: ar oShell = new ActiveXObject("Shell.Application"); var commandtoRun = "C:\\Program Files\\Mozilla Firefox\\firefox.exe" ; oShell.ShellExecute(commandtoRun,"https:/path-to-core-system-web-ui","","open","1"); } So when they click on the icon which is basically an img with the style of cursor: pointer; it does an onclick launch to that code which launches firefox to the web command. If you open our Intranet page in Firefox or Chrome then ActiveX does not run so it just launches in a new tab the link to our core system. This week (1/19) we are going live with a new loan origination system. The LoS system vendor claims they want us to use Chrome for their system. Well a few months ago we changed the default browser to Firefox with GPO's and now the issue is our Intranet page opens in Firefox (which works great) as any other, but how can we craft our link to open the Loan Origination System in Chrome? I call B.S. that is only works in Chrome. It seems to work in Firefox to me, but that's all they want to support so if we need help they won't help us unless we are using it in Chrome. I know I'm not happy about it either. I'm just happy to be rid of IE finally. I like Firefox (and Chrome) but if I can do any tricks to craft a link, maybe a javascript function to launch something like commandtoRun = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", along with the argument with the LoS web URL, that would be great. Thanks!

Wybrane rozwiązanie

It's going to be a long night!!

Okay, but seriously, what I suggest for this is a custom protocol. Since you control the Windows Registry settings, you can define a protocol handler for Google Chrome. Unfortunately, I think you also need an intermediary to separate the custom protocol from the real protocol.

In the past I've defined a custom protocol that runs a VBScript to launch a file in Acrobat. This requires not just the registry change but also a script file dropped on the system. So as an example:

gchrome.reg file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\gchrome]
@="URL:gchrome Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\gchrome\DefaultIcon]
@="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe,0"

[HKEY_CLASSES_ROOT\gchrome\shell]

[HKEY_CLASSES_ROOT\gchrome\shell\open]

[HKEY_CLASSES_ROOT\gchrome\shell\open\command]
@="wscript.exe \"C:\\gchrome.vbs\" \"%1\""
 

gchrome.vbs file for the root of C drive:

Set objArgs = WScript.Arguments
If objArgs(0) <> "" Then
  'MsgBox objArgs(0)
  If InStr(1, objArgs(0), "gchrome:") = 1 Then
    Dim url
    url = Mid(objArgs(0), 9)
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "chrome.exe " & url
    Set WshShell = Nothing
  End If
End If
Set objArgs = Nothing
 

Maybe there's a way to do it more directly, but it's late here so I'll leave it here.

Przeczytaj tę odpowiedź w całym kontekście 👍 0

Wszystkie odpowiedzi (14)

more options

Wybrane rozwiązanie

It's going to be a long night!!

Okay, but seriously, what I suggest for this is a custom protocol. Since you control the Windows Registry settings, you can define a protocol handler for Google Chrome. Unfortunately, I think you also need an intermediary to separate the custom protocol from the real protocol.

In the past I've defined a custom protocol that runs a VBScript to launch a file in Acrobat. This requires not just the registry change but also a script file dropped on the system. So as an example:

gchrome.reg file:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\gchrome]
@="URL:gchrome Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\gchrome\DefaultIcon]
@="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe,0"

[HKEY_CLASSES_ROOT\gchrome\shell]

[HKEY_CLASSES_ROOT\gchrome\shell\open]

[HKEY_CLASSES_ROOT\gchrome\shell\open\command]
@="wscript.exe \"C:\\gchrome.vbs\" \"%1\""
 

gchrome.vbs file for the root of C drive:

Set objArgs = WScript.Arguments
If objArgs(0) <> "" Then
  'MsgBox objArgs(0)
  If InStr(1, objArgs(0), "gchrome:") = 1 Then
    Dim url
    url = Mid(objArgs(0), 9)
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run "chrome.exe " & url
    Set WshShell = Nothing
  End If
End If
Set objArgs = Nothing
 

Maybe there's a way to do it more directly, but it's late here so I'll leave it here.

more options

Oh -- your link to the URL that needs to open in Chrome would change from

https://example.com

to

gchrome:https://example.com

more options

I like jscher2000's idea for it's cleverness, but changing all the URL references might be problematic.

In theory you could use our legacy browser support extension and change the default browser to Chrome instead of IE but I haven't tested that:

https://support.mozilla.org/en-US/kb/legacy-browser-support-extension-windows

You could also use an extension to do it

https://addons.mozilla.org/en-US/firefox/addon/open-in-chrome-browser/

https://addons.mozilla.org/en-US/firefox/addon/open-in-chrome-1/

https://addons.mozilla.org/en-US/firefox/addon/open-with-google-chrome/

It would be straightforward to add policy support to those extensions (I'm documenting that now)

more options

Actually jscher2000's posts worked great.

So I wrapped it around some script, if its IE it invokes ActiveX to launch chrome with the URL... same way we have IE open Firefox with a URL. If its firefox it opens gchrome:https://url If its chrome it just opens https://url

IE just opens it, possibly because its in the Intranet zone and thats pretty lax. Firefox asks if your sure you want to open it using Microsoft Windows Based Script Host. Thankfully there is a box to "remember my choice for gchrome links" (we want to make it easy and less nagging). Chrome just opens it obviously since its just a URL at that point.

Up in the script section: function launch() {

               f = navigator.userAgent.search("Firefox");
               c = navigator.userAgent.search("Chrome");
               if (f > -1) {
                               window.open("gchrome:https://url");
               } else if (c > -1) {
                               window.open("https://url");
               } else {
               var oShell = new ActiveXObject("Shell.Application");
               var commandtoRun = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" ;
               oShell.ShellExecute(commandtoRun,"https://url","","open","1");
               }

}

Down in the body: -img style="cursor: pointer;" onclick="launch()" src="icon.png" border="0" /-

Tie all that together with the registry add and dropping the .vbs file to c:\ it all works as expected.

EDIT: Had to remove the brackets around that img tag - Didn't realize this forum would try to render it as html.

Zmodyfikowany przez kjstech w dniu

more options

That's great to hear!

more options

Your vendor should pay you for that so they can share it with their other customers. ;-)

more options

jscher2000, thats not the first time we joke about that in our IT Department! We usually have to craft custom things here and there to get our end user experience down pat while still working with our vendors.

With your help, we can continue to use Firefox as the default browser and have it automatically open that one system in Chrome since they need it.

My only thing is, when you open the URL, it asks if you want to open it with Microsoft Windows Based Script Host. There is a checkbox that says "Remember my choice for gchrome links". Any way to push that out globally? I see in Options under General > Applications I can go down to gchrome and change it from Always Ask to Use Microsoft Windows Based Script Host.

We do push out an autoconfig.cfg preference file, so is this something I could add in there, or a group policy or something?

Thanks!

more options

I think you should be able to use the Helpers group policy to push that out:

https://github.com/mozilla/policy-templates/blob/master/README.md#helpers

more options

Oh wow Mike, those admx templates are much newer than the ones currently in our domain's policy repository. Looks like its time for me to copy over these newer ones and check out the new settings.

Thanks, that may be the ticket!

more options
more options

If you look at other registry entries, perhaps there also is a way to assign a better name to the handler. I didn't keep notes on what I was testing but if I used certain keys/values from the ChromeHTML key, the dialog mentioned using Chrome to open the link. Ultimately I didn't include any of those as I was uncertain of the consequences.

more options

Well assigning this seems to work in the handlers registry key: { "schemes": {

   "gchrome": {
     "action": "useSystemDefault",
     "ask": false
     }
   }

}


I just want to do more testing. I don't want setting this one to wipe out any existing ones. I'm testing on a machine that doesn't have as many programs installed. Like my machine for example has CSV and some other formats in there that say "Always Ask" whereas my test machine doesn't have some of those but with this registry key it does have gchrome set to open in the windows script host. It does have things like archive file formats, pdf, text documents, pem files and others... so I don't think this is overwriting "everything". I just need to ensure that this is ADDITIVE and not completely wiping out everything. I would hate to research every single file type and application and try to create 100 some entries!

more options

It's definitely additive.

If you want to feel better about it, you can check out the code here:

https://searchfox.org/mozilla-central/source/browser/components/enterprisepolicies/Policies.jsm#2426

We only assign for that specific scheme.

more options

Mike, perfect.

I also just put that handler value into a new GPO attached it to an OU with just some IT computers, including my laptop. I took a screen shot of all my Application Content Type / Action prior so to have a backup. I did a gpupdate /force and re-opened firefox. All my previous entries stayed, and it changed gchrome from Always ask to the window system default which normally is Microsoft Windows Script Based Host.

Winner winner chicken dinner. This rounds out all aspects of this feature. Thanks to BOTH of you guys. A great positive is I have the updated admx templates in our domain now which wow, I have to tell you I was using a much older version... many new options available now. Our end user experience can remain "easy". They click the icon and it just works.