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/