Javascript 从 Internet Explorer 启动 Chrome 浏览器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30611172/
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-08-23 05:27:37  来源:igfitidea点击:

Launch Chrome browser from Internet Explorer

javascriptgoogle-chromeinternet-explorerhyperlink

提问by Kannabiran

We have a web application which has some features that works only in Chrome and I want to launch this web app using Google chrome browser with url of the web app as parameter from Internet explorer via a hyperlink. I tried

我们有一个 Web 应用程序,它具有一些仅适用于 Chrome 的功能,我想使用 Google chrome 浏览器启动此 Web 应用程序,并将 Web 应用程序的 url 作为参数通过超链接从 Internet Explorer 启动。我试过

file:///C:/Program%20Files%20(x86)/Google/Chrome/application/chrome.exe

file:///C:/Program%20Files%20(x86)/Google/Chrome/application/chrome.exe

but it downloads the file + how do I add parameter to the exe.

但它下载文件+如何向exe添加参数。

回答by crowhill

By default, a browser cannot launch another program (plugins and extensions being possible exceptions). If they could, imagine the havoc some malicious user could get up to.

默认情况下,浏览器不能启动另一个程序(插件和扩展可能是例外)。如果可以的话,想象一下一些恶意用户可能会造成的破坏。

I don't think there's going to be a great answer for this, but you could make a .bat file that opens chrome to a particular URL (assuming you're using Windows), download that and click on it after it downloads.

我认为这不会有一个很好的答案,但是您可以制作一个 .bat 文件,将 chrome 打开到特定的 URL(假设您使用的是 Windows),下载该文件并在下载后单击它。

Hereis a useful answer in that case.

在这种情况下,是一个有用的答案。

You could also (theoretically) make an extension or lower the security settings on IE to allow ActiveX controls. Here'sa partial solution. I tried to make something similar a while back and didn't have much luck, but if you're determined...

您还可以(理论上)在 IE 上进行扩展或降低安全设置以允许 ActiveX 控件。是部分解决方案。不久前我尝试过类似的东西,但运气不佳,但是如果您下定决心...

Maybe there's a better way that doesn't involve such complicated solutions?

也许有更好的方法不涉及如此复杂的解决方案?

回答by Chris Done

I found myself needing to achieve this myself. It appears a later release of Chrome had broken the fix described in Adam Fowlers blog.

我发现自己需要自己实现这一目标。似乎后来发布的 Chrome 破坏了 Adam Fowlers 博客中描述的修复。

I got in touch with him and he's now updated his post, providing the now necessary registry changes required to make this work.

我与他取得了联系,他现在更新了他的帖子,提供了使这项工作所需的现在必要的注册表更改。

I've tried this myself and it works nicely.

我自己试过这个,效果很好。

Adam Fowlersblog post - How to launch a URL in Google Chromehttps://www.adamfowlerit.com/2015/05/how-to-launch-a-url-in-google-chrome/

Adam Fowlers博客文章 -如何在 Google Chrome 中启动 URLhttps://www.adamfowlerit.com/2015/05/how-to-launch-a-url-in-google-chrome/

Big thanks to Adam for his time! Hope this helps.

非常感谢亚当的时间!希望这可以帮助。

回答by NetMage

If you can modify the IE permissions on the PCs needed, you can use a javascript link to launch a process. Mine launches a custom program that launches chrome with command line switches and a URL, or opens a web page that indicates they need to contact IT to install Chrome on their PC:

如果您可以修改所需 PC 上的 IE 权限,则可以使用 javascript 链接来启动进程。我的启动了一个自定义程序,该程序使用命令行开关和 URL 启动 chrome,或者打开一个网页,表明他们需要联系 IT 在他们的 PC 上安装 Chrome:

javascript:(new ActiveXObject('Shell.Application')).ShellExecute('\\server\path\LaunchInChrome.exe', '-incognito --use-system-default-printer https://outlook.office365.com/owa/?realm=xxx http://webserver/MissingChrome.html');

But you could modify it to launch chrome.exedirectly instead. You will need to enable Initialize and script ActiveX controls not marked as safe for scripting in the Intranet Zone (I wouldn't recommend this for any other zone).

但是您可以修改它以chrome.exe直接启动。您需要为 Intranet 区域中的脚本编写未标记为安全的 ActiveX 控件启用初始化和脚本(我不建议将其用于任何其他区域)。

回答by Steve Hurcombe

You can use a URI Scheme, Google installs one by default as shared by Adam Fowler here:

您可以使用 URI 方案,谷歌默认安装一个由 Adam Fowler 在此处共享的:

http://www.adamfowlerit.com/2015/05/28/how-to-launch-a-url-in-google-chrome/

http://www.adamfowlerit.com/2015/05/28/how-to-launch-a-url-in-google-chrome/

So you can create a link like this (note the space before the URL):

所以你可以创建一个这样的链接(注意 URL 前的空格):

ChromeHTML:// www.bbc.co.uk

ChromeHTML://www.bbc.co.uk

But it is broken! There's a bug report with Google, see Adam's article. It would be good to add some weight/comments to this bug if you want it fixed.

但是它坏了!Google 有一个错误报告,请参阅 Adam 的文章。如果您希望修复此错误,最好为此错误添加一些权重/评论。

However your next decision depends on whether you have some control over the deployment of your web application because these bugs can be fixed using registry fixes.

但是,您的下一个决定取决于您是否对 Web 应用程序的部署有一定的控制权,因为可以使用注册表修复来修复这些错误。

Interestingly, if you can deploy registry fixes, in theory you could create your own URI schemes.

有趣的是,如果您可以部署注册表修复,理论上您可以创建自己的 URI 方案。

回答by Bender

you have to pass the parameter to chrome, something like this.

你必须将参数传递给 chrome,就像这样。

start chrome https://www.google.com/