What do I need to change so that the 'test' page opens up in the frameset ?
We are trying to do this with a few pages
Can anyone help or point me in the right direction ?
Cheers
Funkyirishman
08-18-2004, 11:11 AM
nathan.russell
Hi,
Just to comment on cjard's post - I think he's suggesting that you have posted a HTML / Javascript question (which is what it is), into a JAVA forum.
That aside, I'll answer it for you anyway !
I've done exactly this; and you are on the right lines, but only written half of the solution.
What you need to do is in each of your pages that are supposed to go into a frame, you need some Javascript at the top which detects the frame - if they are not in the frame that you want them to be in, redirect them to the actual frameset page.
This is what you are doing - BUT, you also need to pass a parameter of the page you have just come from, and your top level frameset page needs to have some Javascript that recognises that parameter and loads that page into the designated frame.
So, here is my code that I use for each of my pages:
<script>
var here=window.location.href
if (here == top.location.href) { top.location.href = 'frameset.htm&page="' +here+ '"' }
</script>
and then my frameset page looks like this:
<script>
function load_MainContent() {
var url=top.location.href
url = url.split("&page=")
if (url.length > 1) {
url[1] = unescape(url[1])
url = url[1].split('"')
url = url[1]
} else {
url="index.htm"
}
top.MainContentFrame.location.href = url
I used a nested frameset, but I guess you can see whats happening here.
The frameset that contains the frame where I want my content to go (the inner frameset) has an onload call to the Javascript function load_MainContent()
The frame that I actually want the content to go into (MainContentFrame) is initially set to have no content - IE. javascript:''
The load_MainContent() function then inspects the URL, looks for the &page= parameter, if there is one it sets the variable url to be that value, otherwise its set to index.htm
Then the location for the MainContentFrame is set to the value of url
Easy really :p
Hope this helps,
Nathan
PS. the phrase javascript:'' used above should not have a space between the a of java and the s of script - it should be all one word. I think that the logic behind this board detects the word and splits it to prevent people running malicious JS code in their postings - I do exactly the same thing on my user forum for the same reason !