Putting data into a variable from a popup window or frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rune Hammerskov

    #1

    Putting data into a variable from a popup window or frame

    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?
  • Dietmar Meier

    #2
    Re: Putting data into a variable from a popup window or frame

    Rune Hammerskov wrote:
    [color=blue]
    > 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.[/color]

    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("ex ample.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


    ciao, dhgm

    Comment

    • Rune Hammerskov

      #3
      Re: Putting data into a variable from a popup window or frame

      Dietmar Meier wrote:[color=blue]
      > Rune Hammerskov wrote:
      >[color=green]
      >> 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.[/color]
      >
      >
      > 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("ex ample.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...op_opener.html
      >
      > ciao, dhgm[/color]


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

      Comment

      Working...