SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast BigKingy's Avatar
    Join Date
    Jun 2004
    Location
    London
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Targetting Parent window, and closing itself....

    Hi,

    What i have is a page that opens a javascript pop-up window (a thank you message for a form). What I then want is the links in the pop-up window to open up in the window that originally opened up the pop-up window (if you get what i mean!)

    I have succesfully done this by using the following code in the original window:

    <script type="text/javascript"> self . name = "first_window"; </script>

    And this code in the pop-up window:

    <a href="../products.htm" target="first_window">Products Page</a>


    So all is working correctly!

    Now, what i wanted to add onto that, is a javascript close function, so that when they click on the link in the pop-up window, the page loads in the other main browser, and the pop-up window closes itself.

    So i added the following to the link in the pop-up box:

    <a href="../products.htm" target="first_window" onclick="window.close()">Products Page</a>

    This works perfectly in Internet Explorer, but sadly doesnt work well in Firefox? Firefox seems to close the pop-up before it loads the link?

    Any ideas how to get this to work in both browsers?

    Is there another method I should be using to achieve this?

    Cheers.

  2. #2
    SitePoint Enthusiast lucius910's Avatar
    Join Date
    Jul 2004
    Location
    Providence, RI
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:
    Code:
     <script>
     function redirectAndClosePop(targetWin, targetUrl){
        try {
        targetWin.location = targetUrl;
        winow.close();
       }
       catch (Error){
     	alert("Woops!\n"+Error.description);
       }
     }
     </script>
      <a href="#" onClick="redirectAndClose('first_window', '../products.htm')" target="first_window">Products Page</a>


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
  •