Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking for opener window if it exists for links, else popup links in new window?

    I am currently using the following function to display any links clicked from the page into the opener or parent window:

    function openLink(url){
    window.opener.location.href = url;
    self.close();
    }

    Is it possible (and if so could someone instruct me) to check if an opener or parent window exists, and if it doesn't then to pop any links clicked into a new full sized window?

    For example, say I accessed this page directly (as opposed to it being popped up from another page) and clicked a link. I'd like that link to open a new window if no parent or opener window exists.

    I'm still learning JavaScript, I hope I've explained this ok. Any help or suggestions would be greatly appreciated.

    Thanks in advance.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following

    <script type="text/javascript" language="javascript">
    <!--

    function chk_opener(url){
    if(!opener){
    newWin=window.open(url)
    }
    }

    //-->
    </script>

    <a href="page1.htm" onclick="chk_opener('page1.htm') ; return false">Page 1</a>
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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