window.open 以post方式传递参数示例代码
时间:2021-03-02 11:44:18|栏目:JavaScript代码|点击: 次
复制代码 代码如下:
//打开新页面并利用post方式传递参数
function openNewPageWithPostData(postAddress,opentype,paramNames,paramValues)
{
var newWindow = window.open(postAddress,opentype);
if (!newWindow)
{
return false;
}
var postDataHtml="<html><head></head><body>";
postDataHtml = postDataHtml + "<form id='postDataForm' method='post' action='"+postAddress+"'>";
if (paramNames && paramValues && (paramNames.length == paramValues.length))
{
for(var i=0 ; i<paramNames.length ; i++)
{
postDataHtml = postDataHtml + "<input type='hidden' name='"+paramNames[i]+"' value='"+paramValues[i]+"'/>";
}
}
postDataHtml = postDataHtml + "</form><script type=\"text/javascript\"> document.getElementById(\"postDataForm\").submit()<script><body><html>";
newWindow.document.write(html);
return newWindow;
}
上一篇:bootstrap-treeview实现多级树形菜单 后台JSON格式如何组织?
栏 目:JavaScript代码
本文标题:window.open 以post方式传递参数示例代码
本文地址:http://www.codeinn.net/misctech/72502.html






