widow open post方法

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;   

你可能感兴趣的:(html,url,input,action)