SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect/Close Popup Window

    I am trying to do two things. I have PDF files but the user has to click on the icon and a contact form will come up in a pop-up window. That window has a form and once the form is completed and properly validated, I want the pop-up window to automatically close and go to "white_papers.com?download=1". It will do everything but it only goes to white_papers.com. How can I get it to go to the entire URL including "?download=1"? The link is http://www.sagacent.com/white_papers.com.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by geniajanssen View Post
    How can I get it to go to the entire URL including "?download=1"?
    By specifying the entire URL as the action attribute of the form.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That won't work on my part. I have the form that I am using to collect information in a popup window. What I want to do is, once all information entered is correct, is to close the popup window and go back to the original page with the "white_papers.php?download=1". Putting this as an action in the form tag will load that page in the popup window. I want the popup window to close and then use the URL above redirected.

  4. #4
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is more detail. When all data is validated and everything is don in the popup window, I use the code :
    echo ("<SCRIPT LANGUAGE='JavaScript'> window.location.href='white_papers.php?download=1'; window.close(); </SCRIPT>");
    The popup window closes but window.location.href does not execute.
    If I remove window.close(), that line works but the popup window does not close and the file loads in the popup window. How do I fix this?

  5. #5
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Typically the child window is not allowed to make changes to the parent.

    What can be done though is for the child to execute a script that exists in the parent.
    Have a function in the parent that changes the location. Then from the child, have it call that parent function just before the child closes itself.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  6. #6
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you give me some example files doing this?

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by geniajanssen View Post
    Can you give me some example files doing this?
    Here are some examples:
    http://www.sitepoint.com/forums/java...ow-108069.html

    So if your parent window had a function called afterChildSubmit() your child window could call that parent function and then close the child with:

    Code javascript:
    window.opener.afterChildSubmit();
    window.close();
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •