【发布时间】:2019-07-24 11:43:53
【问题描述】:
我正在尝试使用 JS 通过来自任何其他浏览器的 POST 请求在 Internet Explorer 中启动 URL(即从 firefox/chrome/safari 打开 IE)
我的网站在谷歌浏览器中运行。在我的一种方法中,我向客户端的 API 发布了一个请求,它向我返回了一个指向另一个网站的 URL。客户端要求我通过 POST 请求在 Internet Explorer 中自动启动此 URL。现在我知道如何通过发布请求启动 URL,但它会在谷歌浏览器的新窗口中启动 URL。我的问题是如何在 Internet Explorer 中通过 POST 启动此 URL?
我正在使用以下代码在 chrome 的新窗口中通过 post 请求打开此 url。
function OpenWindowWithPost(url, windowoption, name, params) {
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", url);
form.setAttribute("target", name);
for (var i in params) {
if (params.hasOwnProperty(i)) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = i;
input.value = params[i];
form.appendChild(input);
}
}
document.body.appendChild(form);
window.open("post.htm", name, windowoption);
form.submit();
document.body.removeChild(form);
}
OpenWindowWithPost(onlyUrl,
"width=730,height=345,left=100,top=100,resizable=yes,scrollbars=yes",
"NewFile", paramsAsObject);
我还尝试通过协议处理程序启动 IE。 (按照这篇文章获取协议处理程序解决方案) Open Internet Explorer from Chrome using a protocol handler (ie:url)
但它只是忽略了我的参数并仅在 IE 中启动基本 URL,这不是我想要的。
有没有一种方法可以同时做这两件事? 1-在 IE 中打开给定的 URL。 2- 通过 POST 请求打开它。
注意:由于客户的要求,我不能在这里使用 GET/Href。
任何帮助将不胜感激。
【问题讨论】:
-
我认为这是不可能的。你只能在同一个浏览器上这样做
标签: javascript jquery internet-explorer redirect post