RE: Javascript that ensures page is in proper frame?

by "tim booker" <timbooker(at)btinternet.com>

 Date:  Sat, 22 Jul 2000 09:03:37 +0100
 To:  "'Mike Taylor'" <lonewolf(at)one.net>,
<hwg-techniques(at)hwg.org>
 In-Reply-To:  one
  todo: View Thread, Original
http://www.webbedenvironments.com/v02/02_15.html



> -----Original Message-----
> From: owner-hwg-techniques(at)hwg.org
> [mailto:owner-hwg-techniques(at)hwg.org]On Behalf Of Mike Taylor
> Sent: 22 July 2000 05:26
> To: hwg-techniques(at)hwg.org
> Subject: Javascript that ensures page is in proper frame?
> 
> 
> The following code will knock a page out of someone else's frame:
> <script language="javascript">
>         if (parent.frames.length != 0) top.location = 
> document.location;
>         </script>
> 
> HOWEVER, if I have a framed site and I want to prevent someone from
> accessing a page of mine that was intended to be inside a frame (this
> happens sometimes in search engines that somehow bypass the "NOINDEX
> NOFOLLOW" meta tag), is there a piece of javascript that would:
> 
> 1. Check to see if the page is inside of my frameset, and if 
> not, then 2.
> Redirect to my main framed page.
> 
> If I had to guess at this, I'd try the following:
> 
> <script language="javascript">
>         if document.framename.location = top.location
> {this.location="http://www.theurlformymainframe.com"}
>  </script>
> 
> I'm not sure if this will really work if the page that is 
> supposed to be
> in a frame is NOT, because the javascript wouldn't KNOW that 
> this page has
> a framename called "X" or whatever. Actually, I just tried this and it
> says that document.myframename is not an object.
> 
> Has anyone attempted or succeeded in what I'm suggesting here?
> 
> Thanks,
> 
> Mike Taylor
> lonewolf(at)one.net
> http://w3.one.net/~lonewolf/
> 
> 
> 

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA