View Full Version : Checking for opener window if it exists for links, else popup links in new window?

03-17-2005, 05:53 PM
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;

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.

Mr J
03-17-2005, 07:44 PM
Please try the following

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

function chk_opener(url){


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