Solved

How can i prevent direct linking to Frames?

Posted on 2003-12-01
6
269 Views
Last Modified: 2010-04-09
Hi,
I have a frame set. But people can still access the individual frame addresses without going throught the main frameset.

For example: instead of going to http://www.citizenerased.com and choosing 'Us' at the top, they can just go directly to http://www.citizenerased.com/pages/us.html

how can i prevent this?

Cheers
0
Comment
Question by:dunkjonesy
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:Timbo87
ID: 9855884
Add this to the <body> tag of all the frames to be displayed but not the page with the frameset:

<body onLoad="
var wl = top.window.location + '';
if(wl.indexOf('htm') >= 0)
window.location = 'http://www.citizenerased.com'">

With this code, if the page is accessed normally through a frameset, it will display, but if they type it into their browser URL, it redirects them to the main page with the frameset.
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9855891
Small change to make it more frames-compatible.

<body onLoad="
var wl = parent.window.location + '';
if(wl.indexOf('htm') >= 0)
parent.window.location = 'http://www.citizenerased.com'">
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 9855904
If you already have some code in your <body> tag, you just need to add this to the <body> tag:

onLoad="var wl = parent.window.location + '';if(wl.indexOf('htm') >= 0) parent.window.location = 'http://www.citizenerased.com'"
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 31

Accepted Solution

by:
GwynforWeb earned 500 total points
ID: 9856053
This works nicely, change the body tags to

<body onload="(top.location != this.location)?true:document.location='http://www.citizenerased.com'">
0
 

Author Comment

by:dunkjonesy
ID: 9856152
thankyou very much people....theres probably more than one answer to this, so i just chose the first one i tried (and the one that looked the simplest)

many thanks!
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9858775
Thanks GfW
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How can I do a Select All on this page? 8 36
Synchronizing CSS load 3 30
Problem with a CSS in a page 2 27
Put shading on half of picture 8 30
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now