www.webdeveloper.com
Results 1 to 3 of 3

Thread: Popup links to Parent Window - backup?

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Posts
    21

    Popup links to Parent Window - backup?

    One of my clients has requested the following...
    - Click a link to open a popup window
    - Click links in the popup window to change content in parent window

    I have this working well at the following test URL - http://pixgroup.com/popup/ (click the links and you'll see that they load in the parent window).

    The problem is that if someone closes the parent window, the links in the popup window no longer work. Is there a way I can code this so the links open in the parent window... but open in a new window if the visitor has closed the parent window?

    Here is the key code snippet...
    Code:
    <a href="javascript:void(0);" onClick="window.opener.location.href='http://www.yahoo.com';">YAHOO
    Last edited by idesign123; 04-24-2013 at 06:13 PM.

  2. #2
    Join Date
    Jan 2011
    Location
    United Kingdom, London
    Posts
    117
    Code:
    <html><head>
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
        <title>Untitled Page</title>
        <script type="text/javascript">
            function openWindow(link) {
                if(window.opener !== null) {
                    alert('open in opener');
                    window.opener.location.href=link;
                    return false;
                } else {
                    return true; 
                }
            }
        </script>
    </head>
    
    <body bgcolor="#ffffff">
    <p><a href="http://yahoo.com" onclick="return openWindow('http://yahoo.com');" target="_blank">YAHOO</a></p>
    <p><a href="http://www.google.com" onclick="return openWindow('http://www.google.com')" target="_blank">GOOGLE</a></p>
    <p><a href="http://www.apple.com" onclick="return openWindow('http://www.apple.com')" target="_blank">APPLE</a></p></p>
    </body></html>
    Last edited by maurycy; 04-25-2013 at 04:20 AM. Reason: formating
    Javascript, jQuery / Prototype & PHP expert ready to complete your work on Freelancer.co.uk - Hire Me at https://www.freelancer.co.uk/users/1...&action=hireme

  3. #3
    Join Date
    Feb 2004
    Posts
    21
    Your code worked perfectly - thank you SOOO much for your help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles