Javascript window.open使用POST传递值
程序开发
2023-09-04 09:01:54
为什么80%的码农都做不了架构师?>>>
https://stackoverflow.com/questions/5684303/javascript-window-open-pass-values-using-post
对于它的价值,这里是以前提供的代码封装在一个函数中。
openWindowWithPost("http://www.example.com/index.php", {p: "view.map",coords: encodeURIComponent(coords)
});
功能定义:
function openWindowWithPost(url, data) {var form = document.createElement("form");form.target = "_blank";form.method = "POST";form.action = url;form.style.display = "none";for (var key in data) {var input = document.createElement("input");input.type = "hidden";input.name = key;input.value = data[key];form.appendChild(input);}document.body.appendChild(form);form.submit();document.body.removeChild(form);
}
翻译到angular 5中 https://seegatesite.com/trick-to-redirect-new-window-or-tab-with-post-method-on-angular-5/
转载于:https://my.oschina.net/lieefu/blog/3023005
标签:
上一篇:
自动轮播插件
下一篇:
相关文章
-
无相关信息