By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,436 Members | 2,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,436 IT Pros & Developers. It's quick & easy.

window.open

P: n/a
Hi,
if I opened a php-page using

... onclick=\"help=window.open('help.php', 'Help',
'innerHeight=400,innerWidth=400,screenX=555,screen Y=250,dependent=Yes,bar=Yes');
....

is there a way to send data to the invoked page (help.php)? Something
like $_POST[....] if I would use a HTML form-submit?
Setting cookies or store data in mysql are not so very elegant solutions.

Can somebody give me hint?

Lajos
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Just add a query string after help.php:

... onclick=\"help=window.open('help.php?a=10&b=20&c=4 0', 'Help',

'innerHeight=400,innerWidth=400,screenX=555,screen Y=250,dependent=Yes,bar=Ye
s');
...

Hope it helps
Henri

"Lajos Kuljo" <ku***@freemail.hu> a écrit dans le message de
news:o0******************@nntpserver.swip.net...
Hi,
if I opened a php-page using

... onclick=\"help=window.open('help.php', 'Help',
'innerHeight=400,innerWidth=400,screenX=555,screen Y=250,dependent=Yes,bar=Ye
s'); ...

is there a way to send data to the invoked page (help.php)? Something
like $_POST[....] if I would use a HTML form-submit?
Setting cookies or store data in mysql are not so very elegant solutions.

Can somebody give me hint?

Lajos


Jul 23 '05 #2

P: n/a
Lajos Kuljo wrote:
Hi,
if I opened a php-page using

... onclick=\"help=window.open('help.php', 'Help',
'innerHeight=400,innerWidth=400,screenX=555,screen Y=250,dependent=Yes,bar=Yes');
...

is there a way to send data to the invoked page (help.php)? Something
like $_POST[....] if I would use a HTML form-submit?
Setting cookies or store data in mysql are not so very elegant solutions.

Can somebody give me hint?

Lajos


window.open(...) is a GET operation, you can not POST data to the page being opened.
However, you can pass approximately 2Kb of data on the URL itself during the GET
operation:

window.open(
'help.php?a=' + clientSideVariable,
'Help',
'...attributes...'
);

If you actually want to POST data, you're going to have to store it in a form and
POST that form:

<form name="myHiddenForm" method="POST" action="help.php" target="Help">
<input type="hidden" name="myHiddenValue" value="">
</form>
<a href="noJS.html"
onclick="submitForm('myHiddenForm');return false;">Help</a>
<script type="text/javascript">
function submitForm(name) {
var f = document.forms[name];
if (f) {
window.newWindowHtml = [
'<html>',
'<head>',
'<title></title>',
'</head>',
'<body onload="',
'var w;',
'if ((w = window.opener) &&',
'(w = w.document) &&',
'(w = w.forms) &&',
'(w = w[\'' + name + '\'])) {',
'w.submit();',
'}',
'window.focus();',
'">',
'</body>',
'</html>'
].join('\n');
window.open(
'javascript:opener.newWindowHtml',
f.target,
'...attributes...'
);
}
}
</script>

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.