window.open

L

Lajos Kuljo

Hi,
if I opened a php-page using

... onclick=\"help=window.open('help.php', 'Help',
'innerHeight=400,innerWidth=400,screenX=555,screenY=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
 
H

Henri

Just add a query string after help.php:

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

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

Hope it helps
Henri
 
G

Grant Wagner

Lajos said:
Hi,
if I opened a php-page using

... onclick=\"help=window.open('help.php', 'Help',
'innerHeight=400,innerWidth=400,screenX=555,screenY=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:eek:pener.newWindowHtml',
f.target,
'...attributes...'
);
}
}
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top