Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2006
    Location
    UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking if named parent window is open ?

    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


    Code:
    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

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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.
    Code:
    if(opener)
    {
    // do something
    }
    else
    {
    // do nothing
    }
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Sep 2006
    Location
    UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •