這篇文章主要介紹了window.open以post方式傳遞參數的方法,需要的朋友可以參考下
代碼如下: //打開新頁面並利用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; }