window.open 以post方式傳遞參數(shù)示例代碼
更新時間:2014年02月27日 11:24:02 作者:
這篇文章主要介紹了window.open以post方式傳遞參數(shù)的方法,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
//打開新頁面并利用post方式傳遞參數(shù)
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;
}
相關(guān)文章
JavaScript實現(xiàn)輸入框(密碼框)出現(xiàn)提示語
有時候我們需要在登陸表單有一些提示語言,比如“請輸入用戶名”和“請輸入密碼”等語言,通過本文給大家介紹JavaScript實現(xiàn)輸入框(密碼框)出現(xiàn)提示語的相關(guān)知識,對js實現(xiàn)輸入框提示相關(guān)知識感興趣的朋友一起學習吧2016-01-01