复制代码 代码如下:
复制代码
//打开新页面并利用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;
}
//打开新页面并利用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;
}
最后
以上就是糊涂手套最近收集整理的关于window.open 以post方式传递参数示例代码的全部内容,更多相关window.open内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复