简体   繁体   English

在另一个浏览器中打开链接:Javascript

[英]Open a link in another browser: Javascript

Is it possible to open a link in another browser using Javascript? 是否可以使用Javascript在其他浏览器中打开链接?

I basically want to open Firefox from Google Chrome. 我基本上想从Google Chrome打开Firefox。 I'm (attempting to) write an extension for chrome, but I can't find anything pointing to be able to do this. 我(尝试)为chrome编写了扩展程序,但找不到任何指向能够做到这一点的东西。

I think I could use NPAPI plugins for Chrome, but they are being deprecated and are very insecure, so are there any alternate options? 我认为我可以将NPAPI插件用于Chrome浏览器,但是它们已被弃用并且非常不安全,因此是否有其他选择?

You can use Native Messaging , paired with a native program which will launch the browser. 您可以将本机消息传递与本机程序配对使用,以启动浏览器。 I would write the native application in something like Python. 我会用Python之类的方式编写本机应用程序。

You did not provide enough info so I can't asses the utility of what I'm about to offer, but here's an option: 您没有提供足够的信息,所以我无法评估我将要提供的实用程序,但是这里有一个选择:

  1. Basically, use URL schemes to launch your application of choice from the browser. 基本上,使用URL方案从浏览器启动您选择的应用程序。 Start reading this SO question - How do I register a custom URL protocol in Windows? 开始阅读这个SO问题- 如何在Windows中注册自定义URL协议? . You'll need to register some prefix - like "firefox://" for it to work. 您需要注册一些前缀,例如“ firefox://”才能起作用。 Should also be possible on other platforms. 在其他平台上也应该可能。

  2. Of course, this assumes that your user has firefox installed and that you can register on their machine. 当然,这假设您的用户安装了firefox,并且可以在其计算机上注册。 If this application is meant for a the general public, you'll need to perform those by some other means (installer?) 如果此应用程序是面向普通大众的,则您需要通过其他方式(安装程序?)来执行这些操作。

Yet another way to go is (as mentioned above) to run some native code via the extension. 还有另一种方法(如上所述)是通过扩展来运行某些本机代码。 Not a simple choice: once again you need to somehow install the native code on the host machine (and you cannot do that via Chrome extensions, for security reasons). 这不是一个简单的选择:您再次需要以某种方式在主机上安装本机代码(出于安全原因,您无法通过Chrome扩展程序执行此操作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM