javascript 从另一个浏览器打开一个浏览器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29235353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 10:16:18  来源:igfitidea点击:

Opening one browser from another browser

javascript

提问by Ark

I am running my web application on Firefox. I have hyperlink on one of the page and when I click on it, it opens another application as a new popup. But that application is not supported on Firefox. So I want to open it in Internet Explorer, i.e., though I am running the application on Firefox, that particular popup should open in Internet explorer. I am using this to open new window:

我在 Firefox 上运行我的网络应用程序。我在其中一个页面上有超链接,当我点击它时,它会打开另一个应用程序作为新的弹出窗口。但 Firefox 不支持该应用程序。所以我想在 Internet Explorer 中打开它,即,虽然我在 Firefox 上运行该应用程序,但该特定弹出窗口应该在 Internet Explorer 中打开。我用它来打开新窗口:

var win = window.open(url, "NewWindow", strFeatures);

回答by Ilmari Karonen

You can't do this with just ordinary JavaScript; as Levi notes, if you could, that would be a usability and security nightmare.

你不能只用普通的 JavaScript 来做到这一点;正如 Levi 指出的那样,如果可以,那将是可用性和安全性的噩梦。

That said, there are a couple of ways you could get something like this to work. For example, a Firefox add-on can launch external programs, so you could write such an add-on to open your app in IE, and ask your users to install it (or have an admin pre-install it for them, if this is e.g. for an in-house app in a managed workplace setting).

也就是说,有几种方法可以让这样的事情发挥作用。例如,Firefox 插件可以启动外部程序,因此您可以编写这样的插件来在 IE 中打开您的应用程序,并要求您的用户安装它(或者让管理员为他们预安装,如果这样的话)例如,用于托管工作场所设置中的内部应用程序)。

Another possibility might be to use a custom URL scheme (like myapp:) to link to your application, and register that URL scheme to be opened in IE(or, rather, in some kind of a wrapper script that takes the custom URL, converts it to a normal HTTP URL, and opens it in IE). Again, though, this requires configuring (and, probably, installing a script on) the end-user's computer, so it's probably only suited for office or similar environments.

另一种可能性可能是使用自定义 URL 方案(如myapp:)链接到您的应用程序,并注册该 URL 方案以在 IE 中打开(或者,更确切地说,在某种采用自定义 URL 的包装器脚本中,将其转换为一个普通的 HTTP URL,并在 IE 中打开它)。不过,这又需要配置(并且可能在其上安装脚本)最终用户的计算机,因此它可能仅适用于办公室或类似环境。

Note that both of these solutions have security implications that you should keep in mind. In particular, any add-on or script you use for them should onlywork for specific URLs that point to your app, and should refuse to open any other URLs someone might try to feed it.

请注意,这两种解决方案都具有您应该牢记的安全隐患。特别是,您为它们使用的任何加载项或脚本应该适用于指向您的应用程序的特定 URL,并且应该拒绝打开任何其他人可能试图提供它的 URL。

In any case, if you're trying to do this for a public website, keep in mind that there's no wayyou can make this work for Linux / Mac users who don't haveIE to begin with. And even many Windows users might be reluctant to use IE (not to mention installing an untrusted extension!) without a verygood reason; after all, there's presumably a reason why they chose to use Firefox (or Chrome or Opera or whatever) in the first place.

在任何情况下,如果你想为一个公共网站做到这一点,请记住,有没有办法可以让这个工作的Linux / Mac用户没有谁具有IE开始。甚至许多Windows用户可能不太愿意使用IE(更不用说安装不可信扩展!)没有一个非常好的理由; 毕竟,他们首先选择使用 Firefox(或 Chrome 或 Opera 或其他)大概是有原因的。

回答by Levi Mootz

That's not possible and for good reason. Just think of what someone clever -- arguably -- could do if they could cause various programs to run on your computer because you clicked a link on a website...

这是不可能的,而且是有充分理由的。想想一个聪明的人——可以说——如果他们可以导致各种程序在你的计算机上运行,​​因为你点击了一个网站上的链接......

This is what you're trying to do...run another native application from clicking a link in a browser.

这就是您想要做的...通过单击浏览器中的链接运行另一个本机应用程序。

Why not just use Internet Explorer for everything since it works for the pop up?

为什么不直接使用 Internet Explorer,因为它适用于弹出窗口?