widow open post方法

来源:互联网 发布:苹果mac如何强制关机 编辑:程序博客网 时间:2024/09/21 09:04

from:http://hi.baidu.com/iorichina/blog/item/5a2b323f20a901fc54e72386.html

  1. function openWindowWithPost(url, name, keys, values) {   
  2.     var newWindow = window.open(url, name);   
  3.     if (!newWindow) return false;   
  4.     var html = "";   
  5.      html += "<html><head></head><body><form id='formid' method='post' action='" + url + "'>";   
  6.     if (keys && values && (keys.length == values.length))   
  7.         for (var i = 0; i < keys.length; i++)   
  8.          html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";   
  9.      html += "</form><script type='text/javascript'>document.getElementById(/"formid/").submit()</script></body></html>";   
  10.      newWindow.document.write(html);   
  11.     return newWindow;