windows - 启动 IE 的自定义协议(protocol)处理程序 - 不一致的结果

标签 windows internet-explorer protocol-handler

我在使自定义协议(protocol)处理程序正确启动 IE 时遇到问题。

这是我正在尝试做的: 我有我的网页,用户需要在 chrome 中访问。该页面包含一些外部网络应用程序的链接。这些外部网络应用程序只能在 Internet Explorer 上运行良好。 单击链接时,我必须以某种方式使用外部 Web 应用程序的 URL 启动 IE。

客户不愿意使用像 IETab 这样的插件来启动这些外部应用程序。

因此,我尝试定义一个自定义协议(protocol)处理程序,它将目标 URL 作为参数并使用目标 URL 启动 Internet Explorer 浏览器。

只要没有已打开的 IE 窗口,它似乎就可以正常工作。但是当已经有一个 IE 实例在运行时,行为会有所不同。

我使用了以下代码:

在 HTML 文件中:

function launchIE(target){
window.location = "launchIE:\"http://external.url.com?param1=1&param2=2\"";
}

我已通过将以下内容添加到 Windows 注册表中,将处理程序注册到自定义协议(protocol)“launchIE”:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\launchIE]
"URL Protocol"="\"\""
@="\"URL:launchIE Protocol\"" 

[HKEY_CLASSES_ROOT\launchIE\DefaultIcon] 
@="\"iexplore.exe,1\"" 

[HKEY_CLASSES_ROOT\launchIE\shell]
[HKEY_CLASSES_ROOT\launchIE\shell\open]
[HKEY_CLASSES_ROOT\launchIE\shell\open\command] 
@="cmd /C set myvar=%1 & call set myvar=%%myvar:launchIE:=%% & call start /separate iexplore %%myvar%% & exit"

通过上述设置,当我单击按钮触发上述 javascript 时,我启动了 Internet Explorer。 IE打开网址http://external.url.com?param1=1&param2=2如果没有已打开的 Internet Explorer 实例,则正确。 screenshot of IE showing correct URL

但是,如果已经有一个 IE 实例打开(由用户手动打开或由于之前单击我页面上的按钮),IE 将打开一个不正确的 URL http://%22http//external.url.com?param1=1&param2=2screenshot of IE showing wrong URL

请帮忙...我该如何解决这个问题?

我正在使用 Windows 10 和 IE 11。

最佳答案

我通过创建一个单独的批处理文件并用双引号将 URL 括起来解决了这个问题:

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
@="cmd /C c:/tmp/ie.bat \"%1\" & exit"

ie.bat:

set var=%1
set var=%var:ie:=%
call start /separate iexplore %var%
exit

关于windows - 启动 IE 的自定义协议(protocol)处理程序 - 不一致的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47096525/

相关文章:

php - 即 : input type ="file" multiple

c# - 如何在 Windows 8 上正确注册协议(protocol)处理程序?

windows - 将参数传递给 powershell 脚本

windows - 如何在不忽略相邻命令的情况下在命令行中可靠地使用 `rem`?

javascript - 由于某种原因,图像未在 IE 8 或 IE 9 中显示

java - Tomcat 9 SSL/TLS - 无法初始化组件错误

javascript - chrome 中的自定义协议(protocol)处理程序

windows - 批量请求用户输入(/P)时换行?

Windows 10 Mobile - 无法隐藏状态栏(StatusBar 在上下文中不存在)

c++ - 检测 Windows (IE) 代理设置更改