When we do a window.open()
, is there an option to specify method = POST
? Since by default, it is GET
?
What I want is this. The parent window has some form parameters (many in number) and they should be sent to the server on window.open()
. It is not a good idea to append all of them in the GET
url using query string.
You could use window.open()
to open an empty window, with a name. Then you could use a <form>
with a "target" attribute referring to that new window's name, and post it.
edit OK here's the idea. You have a form on the page, and it can be hidden:
<form id='theForm' method='post' action='/your/action' target='TheNewWindow'>
<input type='hidden' name='param_1' value='whatever'>
</form>
Then you get the results into your window like this:
window.open('about:blank', 'TheNewWindow');
document.getElementById('theForm').submit();
Make sure that the window name you use is a valid identifier (like a JavaScript variable name), or IE will get upset.
Here is a jsfiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With