window.open 以post方式传递参数示例代码_Javascript教程-查字典教程网
window.open 以post方式传递参数示例代码
window.open 以post方式传递参数示例代码
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下://打开新页面并利用post方式传递参数functionopenNewPageWithPostData(postAddre...

复制代码 代码如下:

//打开新页面并利用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;

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类