...

View Full Version : Checking if named parent window is open ?



igrahaml
09-24-2006, 08:31 PM
I run Jalbum as a popup type window from an index in my main website, the user chooses and opens the album looks at the images, reads the blurb then clicks a close button to return to the still open main website and possibly select another album – works ok no problem.
But it occurred to me (eventually) that a visitor could get directly to an album from the likes of Google image search, and not be aware that the main website exists - No problem I’ll just put a link to the main website on each album.

I got that to work – It’s doing what I want – opens my main website, closes popup window.

I then thought ‘wouldn’t it be good if the script was to check if the main web site page was the parent that opened the album and not opened from (for instance) Google image search (different parents)
 If main website is open - just close popup
 If main website not open - open my main website, close popup window.
Makes a slight differences as to if the user is back to album index or the front of my main website.

Is this doing what I think its doing? Checking if my website – page named 'Sunderland Mountaineering club' is open



function newwindow2()
{
if (typeof('Sunderland Mountaineering club') != "undefined")
{
window.open('http://www.lovatt.co.uk/','Sunderland Mountaineering club','directories,scrollbars,menubar,resizable,toolbar,location,status,fullscreen');
top.window.close()
}
else
{
top.window.close()
}
}


If it’s not doing what I think its doing how would I make it do so?
Wouldn’t at all surprise me if it’s total b#####ks

_Aerospace_Eng_
09-24-2006, 11:38 PM
Just do an if statement checking for the opener, the opener will be the page that opens the popup. If one isn't found then it is said that its either not open or the album wasn't opened through the index page.

if(opener)
{
// do something
}
else
{
// do nothing
}

igrahaml
09-25-2006, 10:20 AM
Unless I’m misunderstanding how the opener works, an ‘if’ statement on the opener would find my parent if that was the opener but would also find Google images if that was the opener, therefore the ‘if’ wouldn’t differentiate between the two – I want to check for my opener

It would be nice if my logic was wrong – is it?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum