Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maintaining frames when website accessed from search engine 1

Status
Not open for further replies.

EdPennington

Technical User
Dec 21, 2004
1
GB
Hi,
I am new to Frontpage, and have created a website which has 3 frames - top header, left hand menu, and main section.
The idea is that you use the left hand menu to access all the pages on the site, which appear in the central section.
My problem is that on some search engines, the link is not to the home page, but to another page on the site. If selected, this page appears on its own in the web browser as a single frame.
Is there a way to prevent this happening, and instead to direct people to the 3-frame home page?
Thanks
 
You can achieve this by adding this bit of script to the pages you wish to keep within their frames:

if (top == self) self.location.href = "theframeset.html";

this doesnt open the selected page in its frame the frames page will open its default pages.




Aaron Taylor
John Mutch Electronics
 
I found this code somewhere in one of the threads. It will force your page to open within the frames, AND redirect you to the page that was intended to be opened.

-----
-----
-----

PLACE THIS IN YOUR MAIN FRAME PAGE WITHIN HEAD TAGS (where you specify your framesets and junk)

<script type="text/javascript">
<!--
window.onload = function checkUrl() {
var qs = parent.location.search.split(/start=/i);
if (qs.length > 1) {
parent.[[name of content frame]].location = qs[1];
}
}
//-->
</script>

*remember to remove the double brackets above when you put in the name of your main content frame (center frame).

-----
-----
-----

PLACE THIS IN ALL OF YOUR OTHER PAGES WITHIN THE HEAD TAGS

<SCRIPT type="text/javascript">
<!--
if (parent.frames.length == 0) {
top.location.href="}
//-->
</SCRIPT>

*The first part redirects the page to your main frames page (so that your site loads within frames). The second part tells the main frame page which page was trying to load. By doing this, the main frames page will load the correct page into the center content frame.

*also note, that when you specify the page that is supposed to load, you need to use correct pathing. For example:

superdeals.html is located in the ROOT:\Content\Deals folder. Your main frames page (index.html) is located in the ROOT: folder. Your main content frame is called "details". Here is your code:

*INDEX.HTML*
<html><head>
<script type="text/javascript">
<!--
window.onload = function checkUrl() {
var qs = parent.location.search.split(/start=/i);
if (qs.length > 1) {
parent.details.location = qs[1];
}
}
//-->
</script>
</head>
<body>
frameset info here
</body>
</html>

*SUPERDEALS.HTML*
<html><head>
<SCRIPT type="text/javascript">
<!--
if (parent.frames.length == 0) {
top.location.href="}
//-->
</SCRIPT>
</head>
<body>
superdeals items here
</body>
</html>

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top