|
The problem is that the content of your frame is a seperate HTML file. There is no realtionship from the frame content to the frameset! Only the other way - from frameset to frame content. So there is no way to find out to which frame set an html page belongs.
Cheers
Peter
|
|
Expert:
|
PeterNZ
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
05:12
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
I believe it's possible with javascript to ask if a given part of the frameset has a parent, if that is not the case you reload the parent.
I don't remember the code for it...
|
|
Expert:
|
theDude
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
09:40
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Just set the "target" attribute of the <A> tag to "_parent".
For example:
<a href="new_link.htm" target="_parent">new link</a>
|
|
Expert:
|
andriy.kharuk
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
10:20
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
This has to be automatic, as far as I understood, so an anchor-link is not going to do it, andriy.
If you use this javascript in your framesets children pages, I believe it should work:
if (top == self)
{
location = 'parent_frameset_page.html';
}
|
|
Expert:
|
theDude
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
10:47
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|
|
Expert:
|
rosv
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
22:43
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
Sorry guys, but how does a child doc know who is its parent? There is no relationship upwards, as far as I know. Only down from parent to chld. You have a <FRAMESET> in your page which contains <FRAME> which has an attribute for its source like <SRC="Content.html"> where Content.html is just a normal html page. In the code of Content.html is no relationship to the frame etc. So if you do a http://www.mydomain.com/Content.html you have no way of finding out in which frame Content.html belongs! And even if you would be able to find out, you still have to find the frameset to which the frame belongs!
Setting the taget of a link to _parent doesn't help. The question was, how can I force a page to be opened in its frameset if for example the page is found by Google etc. You can't influence the links on teh google serach results page! And by the way, _parent forces the browser to open a page in the same window as opposed in a new window.
But I was thinking about this problem. And I thought the only way could be, that you prevent the page to be loaded at all and redirect to it's parent page. But this has to be hardcoded in the page itself. So if you open the page, you have a java script which says "Hey, I am not supposed to be loaded directly, instead load MyParent.html". I found a script on this webpage: http://www.codelifter.com/main/javascrip...> http://www.codelifter.com/main/javascrip.../a>
============================================================
Script: Open Page in Frameset Script
Functions: If a page is intended to be opened only within
a frameset, this script refers the browser
immediately to the frameset page
Browsers: All
Author: etLux
============================================================
Put the following script in the head of your page. Set the
url of the frameset page where shown below.
<script>
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
if (parent.location.href == self.location.href){
// change the url below to the url of the
// frameset page...
window.location.href = 'index.html'
}
</script>
============================================================
I tested it and it works. But now I am confused. Because I don't know why it works. There is no relationship from child to parent, only Parent to child! The script even works if the child page is in a subfolder folder of the parent page. Even if it is part of another web site! So please explain someone to me how a child knows which page its parent is!!!
Cheers
Peter
|
|
Expert:
|
PeterNZ
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
23:17
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Hehe, Peter, you seem to get to the same conclusion although you dismiss it at the beginning?!
I believe it's the same as when you detect the opener from the page that was opened from another page.
Of course a page in itself opened directly has no idea of who is it's parent. But if it was called/opened in a frameset, it does know who the frame parent is. So basically you're asking from that page whether the page is in a frameset or not, and if it isn't it opens its parent page, which then opens the child page as it should.
Anyway, I would not recommend using frames unless you have some very good reasons for it. In general the disadvantages are bigger than the advantages.
|
|
Expert:
|
theDude
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
23:29
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
i think this question requires a summary... :)
|
|
Expert:
|
theDude
|
|
Date:
|
Aug 30, 2006
|
|
Time:
|
23:30
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|
|
|
|
This question has been answered, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.
|
|