Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can i prevent direct linking to Frames?

Posted on 2003-12-01
6
Medium Priority
?
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 31

Accepted Solution

by:
GwynforWeb earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

688 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