[JavaScript]js中window.open新窗口怎么实现post方式的参数传递
看到过这篇介绍没有搞明白今天看到有篇文章写到windows.open可以post方式传递参数,就赶紧照作看看,结果是可行的,感谢撰写这篇文章的作者~/***window....
看到过这篇介绍没有搞明白
今天看到有篇文章写到 windows.open 可以post方式传递参数,就赶紧照作看看,结果是可行的,
感谢撰写这篇文章的作者~
/**
* window.open with post method
*/
function openWindowWithPost(url, name, keys, values) {
var newWindow = window.open(url, name);
if (!newWindow){
return false;
}
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
if (keys && values && (keys.length == values.length)){
for ( var i = 0; i < keys.length; i++){
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
}
}
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
newWindow.document.write(html);
return newWindow;
}
详细参考网址:http:// www. dotblogs. com.tw/puma/archive/2008/09/03/5288.aspx 展开
今天看到有篇文章写到 windows.open 可以post方式传递参数,就赶紧照作看看,结果是可行的,
感谢撰写这篇文章的作者~
/**
* window.open with post method
*/
function openWindowWithPost(url, name, keys, values) {
var newWindow = window.open(url, name);
if (!newWindow){
return false;
}
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";
if (keys && values && (keys.length == values.length)){
for ( var i = 0; i < keys.length; i++){
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
}
}
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";
newWindow.document.write(html);
return newWindow;
}
详细参考网址:http:// www. dotblogs. com.tw/puma/archive/2008/09/03/5288.aspx 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询