Force a window into a frameset using JavaScript - sub-folders problem.
Hello.
I am using a JavaScript to force a window into a frameset if a user has namaged to open a page that shuld not be viewed alone.
The difficulty was that I wanted the page they were attempting to view to appear in the bottom frame of the frameset. I found a script that works, but am having some trouble when the page they want to see is in a subfolder.
Here is the code for index.html - the frameset:
!
!
And in the head of every page that should not be seen outside of the frameset I have:
!
Anyone openeing 'page.html' will be sent to the frameset, but in the tom frame they will see 'page.html', not 'contact.html' as defined in the frameset.
Now, the problem.
This works 100% if all pages are in the same folder, BUT not f the page I want to force into the frames is in a sub folder. I used the following code in the page in the sub folder:
!
Now, I can see noe reason why this wouldn't work, but it fails. The browser appeasrs to try and send you between 2 pages and just freaks out!
I tried pointing it to a different file in the subfolder so rather than 'page.html' specified 'page1.html' and that works fine as long as the script is not in 'page1.html'. It only fails if the page you point to has the script in the top line.
This is driving me nuts. I can't see why it would do this. A 'quick fix' would be just to keep everything in the one folder... But wiwht more than 200 pages in subfolders (so far) updating all of my links would be a mammoth task.
Any help would be fantastic!
Status:
Open Jan 02, 2008 - 04:46 AM
browsers, JavaScript, web development
1answer
Answer
Jan 02, 2008 - 10:32 PM
OK, I have solved it myself.
I simply replaced the script in the head of every document that I wanted to force into frames with:
!
This works with subfolders as you would expect by using:
!
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment