By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 978 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

Page should detect parent.window

P: n/a
Hi,

I'm sorry if this has been asked before. I'm a designer and occasional
javascript hacker, not a javascript writer. I cannot believe I have
spent over 4 hours searching for this on Google and nothing I have found
solves this silly little problem.

Background
----------
I have been assigned a poorly-designed site to SEO. It has a number of
popup pages which the client refuses to remove.

The Problem
-----------
These popup pages have already been indexed by Google and when they are
clicked on from a page of results they obviously display with no
navigation menu because they are designed to be standalone popups.

The Solution
------------
If the popups are called from the site's home page (the only page from
where these popups are called) then they display as above. If these
popups are called from anywhere else (e.g. a search result on Google)
then the page should either refresh using self.location.href to the
site's home page or maybe use document.write to include a link back to
the site's home page.

I have determined that I need to name the parent.window and that I need
to detect that name when the popup is loaded. But I cannot, cannot find
any tutorial on how to achieve this, yet there are millions of popup
pages in sites that must have this very problem. If anybody could help
me with this I would be very grateful.
Jul 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jessica wrote:
Hi,

I'm sorry if this has been asked before. I'm a designer and occasional
javascript hacker, not a javascript writer. I cannot believe I have
spent over 4 hours searching for this on Google and nothing I have found
solves this silly little problem.

Background
----------
I have been assigned a poorly-designed site to SEO. It has a number of
popup pages which the client refuses to remove.

The Problem
-----------
These popup pages have already been indexed by Google and when they are
clicked on from a page of results they obviously display with no
navigation menu because they are designed to be standalone popups.

The Solution
------------
If the popups are called from the site's home page (the only page from
where these popups are called) then they display as above. If these
popups are called from anywhere else (e.g. a search result on Google)
then the page should either refresh using self.location.href to the
site's home page or maybe use document.write to include a link back to
the site's home page.

I have determined that I need to name the parent.window and that I need
to detect that name when the popup is loaded. But I cannot, cannot find
any tutorial on how to achieve this, yet there are millions of popup
pages in sites that must have this very problem. If anybody could help
me with this I would be very grateful.
I did it... and I did it all by myself!!

Here is the code should anybody else wish to use it:

<script language="javascript">
<!-- // hide from older browsers

function checkOpener(page)
{
if (opener && !opener.closed)
{
opener.location='../index.php';
}
else
{
self.location.href = "../index.php";
}
}
//-->
</script>

</head>
<body onLoad="checkOpener('../index.php')">

If you paste this into your popup window and load that into a browser
window it will automatically refresh to "../index.php" but when you
click the link on "../index.php" that opens the popup window it does
what it is supposed to do, nothing. Obviously you change the
opener.location to whatever the page is called that contains the link to
the popup.

I'm very pleased with myself and I couldn't have done it without the
help of irt.org, whose tips and tricks pointed me in the right direction.

Jess
Jul 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.