Putting data into a variable from a popup window or frame

  • Thread starter Rune Hammerskov
  • Start date
R

Rune Hammerskov

I have a javascript where the following line is used prompt the user for
a url.

# szURL = prompt("Enter a URL:", "");

The problem is that I would like to open a php script instead of the
prompt. In that php script the user should then be able to select a link
and the information passed back to the 'szURL' variable.
Is this possible?
 
D

Dietmar Meier

Rune said:
I have a javascript where the following line is used prompt the user
for a url.

# szURL = prompt("Enter a URL:", "");

The problem is that I would like to open a php script instead of the
prompt. In that php script the user should then be able to select a
link and the information passed back to the 'szURL' variable.

If you now have

szURL = prompt("Enter a URL:", "");
// do something with szURL ...

then use instead of that

window.szURL = -1; // or any other value that indicates no selection
window.open("example.php");
function continue() {
// do something with window.szURL ...
}

and in the document your PHP script creates something like

if (opener
&& !opener.closed
&& typeof opener.continue != "undefined"
&& typeof opener.szURL != "undefined"
) {
opener.szURL = ...
opener.continue();
self.close();
}

See a similar example at
http://www.innoline-systemtechnik.de/dhgm/fillpop_opener.html

ciao, dhgm
 
R

Rune Hammerskov

Dietmar said:
If you now have

szURL = prompt("Enter a URL:", "");
// do something with szURL ...

then use instead of that

window.szURL = -1; // or any other value that indicates no selection
window.open("example.php");
function continue() {
// do something with window.szURL ...
}

and in the document your PHP script creates something like

if (opener
&& !opener.closed
&& typeof opener.continue != "undefined"
&& typeof opener.szURL != "undefined"
) {
opener.szURL = ...
opener.continue();
self.close();
}

See a similar example at
http://www.innoline-systemtechnik.de/dhgm/fillpop_opener.html

ciao, dhgm


Thank you very much, that was exactly what I was looking for.
 

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
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top