homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Javascript help
Changing the original window from a pop-up

 10:36 pm on Jul 7, 2002 (gmt 0)

My website has a simple opening page the ‘Welcomes’ the viewer and has a link the launches a popup window in which the contents of the site can be viewed.

When the popup window is closed the parent window still contains the ‘welcome’ message. However I’d like to have this page change automatically while the popup window is open to a ‘thanks for visiting’ page.

This way the viewer would see my 'thanks for visiting' message when they close thw popup window

I’ve been trying to write a simple script using “onload” in the popup window that would change the url in the parent window but I can’t get it to work.

Any suggestion, any help appreciated.



 1:18 am on Jul 8, 2002 (gmt 0)

Welcome to the forum, flashmastermak. Try this:

<body onLoad="window.opener.parent.location='thanks.html'">


 3:04 am on Jul 8, 2002 (gmt 0)

thanks tedster

It works perfectly



 8:51 am on Jul 8, 2002 (gmt 0)

To prevent ugly JavaScript errors in case somebody comes to your pop-up content via an SERP or something else goes wrong it may be worth checking that there is an opener and it hasn't been closed:

<body onload="if (window.opener && !window.opener.closed){window.opener.parent.location='thanks.html';}">


 4:01 pm on Jul 8, 2002 (gmt 0)

I see what you mean, I hadn’t thought of that.

Is there or could there be a script that detected if a visitor is coming from a link other than the homepage and if they are redirected them to the home page?



 4:19 pm on Jul 8, 2002 (gmt 0)

As the thanks.html URL isn't specified anywhere other than in your scripting it's probably not that likely to get picked up by the SE spiders. Any SEOs seen them picking up scripted URLs before?

detected if a visitor is coming from a link other than the homepage

Tricky and getting fiddly. You could try the following:

function myPage_Load()
if (window.opener)
{//we have an opener window so try to load the thanks page
if (window.opener.closed)
{// the opener window has since closed - open a new one.
{// load the thanks page into the opening window
window.opener.top.location.href = 'thanks.htm';
{//we have no opener so redirect to home, use replace so as not to
//create a loop in the browser history

<body onload="myPage_Load()">

You'll see that the code's getting a little bloated - it's up to you how far you go with it.


 9:39 pm on Jul 8, 2002 (gmt 0)


thanks for the input, It's looks like a really cool script I'm going to try in out first chance I get.

I'll keep you posted

Thanks mak

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved