1. 程式人生 > >前端js再新視窗開啟頁面,以post傳遞引數方式

前端js再新視窗開啟頁面,以post傳遞引數方式

//前端js開啟新頁面,以post傳遞引數

 以下url為請求地址,beginTime為我所需傳遞的引數,以下方法就是替換成form表單提交的方式實現此功能

var newWindow = window.open(url,"");    

var html = "";

html += "<html><head></head><body><form id='formid' method='post' action='"+url+"'>";

html += "<input type='hidden' name='beginTime' value='"

 + beginTime +"'/>";

html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</script></body></html>";

newWindow.document.write(html);