Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 7th, 2004, 11:06 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default Determine if Parent Document Exists

I have a page that contains an IFRAME. There is a possibility that a search engine will direct a visitor directly to the page contained in the IFRAME, and so within that page I would like to include some Javascript that can determine if the parent page is present or has a specific URL, and then either display a message with a link to the parent page, or automatically redirect them to the home page.

I need help How-to determine if the parent exists or has a specific URL, and how to redirect them to a specific URL (if that is possible)

Thanks in advance

Mike
EchoVue.com
__________________
Mike
EchoVue.com
Reply With Quote
  #2 (permalink)  
Old December 7th, 2004, 11:26 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

In the code of your iFrame add this JavaScript:

if(!window.parent||parent.location != "YOUR PARENT URL")
window.location = "YOUR PARENT URL";

hth

-Snib - http://www.snibworks.com
Where will you be in 100 years?
Reply With Quote
  #3 (permalink)  
Old December 7th, 2004, 11:36 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Fantastic! That worked great. Thanks a million.

Mike
EchoVue.com
Reply With Quote
  #4 (permalink)  
Old December 8th, 2004, 12:31 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Well, it worked great until I uploaded it to my site. It started an eternal loop, continually loading the parent into the IFRAME.

This is an edited reply with how I fixed it. I used alerts() to determine what the location of the parent was and realized that the parent required a / on the end of it.

It works great now.

Mike
EchoVue.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
document() - check if a file exists N.Todd XSLT 2 September 19th, 2007 05:50 AM
Determine If A Tag or Node Exists coolpeep Classic ASP XML 2 July 20th, 2006 06:16 PM
Determine if numeric Scootterp Access VBA 4 March 2nd, 2006 08:44 AM
howto test document exists folklayer XSLT 2 October 19th, 2005 05:56 PM
Determine OS adman Beginning VB 6 2 January 5th, 2004 02:26 AM



All times are GMT -4. The time now is 03:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.