別ウィンドウを開く際にPOSTでパラメータを送るには、
window.openで空のページを開いてから
そこに対してSUBMITを行います。
ページ上のフォームからもできますし、
フォームのないページでもPOSTできます。
まずは、ページ上のフォームからSUBMITする場合:
JavaScript
| 1 2 3 4 5 6 7 | function post_open() {   window.open('', 'new_window');   document.form1.action = 'page2.php';   document.form1.method = 'POST';   document.form1.target = 'new_window';   document.form1.submit(); } | 
HTML
| 1 2 3 4 5 | <form name="form1"> <input type="hidden" name="param1" value="hoge"/> <input type="hidden" name="param2" value="hage"/> <input type="button" value="送信" onclick="post_open();"/> </form> | 
開いたウィンドウに名前をつけて、
その名前をtargetで指定するだけなので難しくないですね。
次に、フォームのないページでPOSTする場合:
※jQueryを使っています。
JavaScript
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | function post_open() {   window.open('', 'new_window');   // フォームを動的に生成   var html = '<form id="temp_form" style="display:none;">';   var data = {     'param1': 'hoge'    ,'param2': 'hage'   };   for(var x in data) {     if(data[x] == undefined || data[x] == null) {       continue;     }     var _val = data[x].replace(/'/g, '\'');     html += "<input type='hidden' name='" + x + "' value='" + _val + "' >";   }   html += '</form>';   $("body").append(html);   $('#temp_form').action = 'page2.php';   $('#temp_form').method = 'POST';   $('#temp_form').target = 'new_window';   $('#temp_form').submit();   // フォームを削除   $('#temp_form').remove(); } | 
