Javascript window.open使用POST传递值 [英] Javascript window.open pass values using POST
问题描述
我有一个javascript函数,它使用window.open调用另一个页面并返回结果。
以下是我的代码部分:
var windowFeatures =status = 0,toolbar = 0,location = 0,menubar = 0,directories = 0,resizable = 1,scrollbars = 1 ;
window.open('http://www.domain.com/index.php?p=view.map&coords='+ encodeURIComponent(coords),'JobWindow',windowFeatures);
现在我的问题是我传递了很多数据让GET处理,我需要通过它使用POST方法。
如何使用POST方法将上面的代码转换为打开页面而无需在页面上实现所有表单(页面列出了100个订单与供应商名单 - 我试图映射供应商)
我使用了上述的变体,而不是打印我创建了一个表单并将其提交给第三方url:
var mapForm = document.createElement(form);
mapForm.target =地图;
mapForm.method =POST; //如果适当,可以使用后
mapForm.action =http://www.url.com/map.php;
var mapInput = document.createElement(input);
mapInput.type =text;
mapInput.name =addrs;
mapInput.value = data;
mapForm.appendChild(mapInput);
document.body.appendChild(mapForm);
map = window.open(,Map,status = 0,title = 0,height = 600,width = 800,scrollbars = 1);
if(map){
mapForm.submit();
} else {
alert('您必须允许此地图的弹出窗口才能工作。
}
I have a javascript function that uses window.open to call another page and returning the result.
Here is the section of my code:
var windowFeatures = "status=0, toolbar=0, location=0, menubar=0, directories=0, resizable=1, scrollbars=1";
window.open ('http://www.domain.com/index.php?p=view.map&coords=' + encodeURIComponent(coords), 'JobWindow', windowFeatures);
My problem now is that I am passing to much data for the GET to handle and I need to pass it using the POST method.
How can I convert the code above to open the page using the POST method without implement forms all over the page (the page lists 100's of orders with a list of suppliers - I am trying to map the suppliers)
I used a variation of the above but instead of printing html I built a form and submitted it to the 3rd party url:
var mapForm = document.createElement("form");
mapForm.target = "Map";
mapForm.method = "POST"; // or "post" if appropriate
mapForm.action = "http://www.url.com/map.php";
var mapInput = document.createElement("input");
mapInput.type = "text";
mapInput.name = "addrs";
mapInput.value = data;
mapForm.appendChild(mapInput);
document.body.appendChild(mapForm);
map = window.open("", "Map", "status=0,title=0,height=600,width=800,scrollbars=1");
if (map) {
mapForm.submit();
} else {
alert('You must allow popups for this map to work.');
}
这篇关于Javascript window.open使用POST传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!