Click to See Complete Forum and Search --> : redirect to parent, close popup


teresa
11-12-2003, 08:46 AM
I want users to be able to click on a popup and have it open a new url in their parent window and close the popup at the same time.

can anyone help?

here's my code:

<body onClick="updateParent('contest.htm');window.close();">

Charles
11-12-2003, 08:51 AM
There are a couple of ways to do this. How do you want it to work for the 13% of users who do not use JavaScript?

teresa
11-12-2003, 08:56 AM
My client wants to promote a contest with a popup, for users without Javascript there will be a explanation of the contest on the home page and a page to which users can sign up for the contest.

So I hope we have our bases covered, the client just specifically asked for a popup.

Charles
11-12-2003, 09:00 AM
<body onclick="if (top.opener && !top.opener.closed) {top.opener.location = 'contest.htm'} else {window.open('contest.htm')}">

teresa
11-12-2003, 09:06 AM
finally!! thank you, that code actually loads the new html document in the parent window, but it also loaded the new html document in the popup window and didn't close itself.

:(

Charles
11-12-2003, 09:11 AM
<body onclick="if (top.opener && !top.opener.closed) {top.opener.location = 'contest.htm'} else {window.open('contest.htm')}; top.close()">

And if you are truing to trigger that from a link instead then use:

<a href="contest.htm" onclick="if (top.opener && !top.opener.closed) {top.opener.location = this.href} else {window.open(this.href)}; top.close(); return false">

teresa
11-12-2003, 09:18 AM
beautiful!

the "<a href="contest.htm" onclick="if (top.opener && !top.opener.closed) {top.opener.location = this.href} else {window.open(this.href)}; top.close(); return false">" worked!

I don't get a "link hand" when I rollover the popup but it works!!!

thanks charles