Reputation: 537
I would like to open a new window with javascript and pass POST parameters to it. I've tried a lot of things.
My latest code looks like this so far, but not working (I haven't tried to pass post parameters but after it will work I can only add hidden input to make it work. I guess.):
<form method="POST" name="showgraph" onsubmit="javascript:window.open('graph.php', 'Graph', 'scrollbars=yes,titlebar=no,top=300,left=400');" action="javascript:void(0)">
<a href="#" onClick="document.showgraph.submit();">Show graph</a>
</form>
Upvotes: 1
Views: 5897
Reputation: 22984
If you have control over the initial page, why not just creat JavaScript variables with PHP?
<script type="text/javascript">
<?php
foreach ($_POST as $key => $val)
{
echo "var php_$key = $val;";
}
?>
</script>
Then, you can pass the js vars in the query string of the URL parameter of window.open
.
Upvotes: 0
Reputation: 2629
You need to create hidden form with target="_blank"
and submit it with javascript. It is not possible to pass POST
parameters using window.open
method. For more details visit this link
Upvotes: 2