Forum Moderators: open
I have a frames website.
I'm using a script similar to the one in this thread [webmasterworld.com...] to force content pages to load inside the frameset.
I've added <noframes> tags on every content page. Inside these tags I have basic links to every other content page. The (desired) result is that a user with a noframes browser should see a fully functional website with all the content and should be able to browse to other content pages using the links defined inside the <noframes> tags on every content page. (frames-supporting browsers will not see these links and will use a navigation toolbar in another frame to navigate instead)
The problem is the script forces the frameset to be loaded, but on a noframes browser this results in a blank page being shown. So I now want to enhance that javascript to only force the frameset to load if the browser supports frames (thus enabling a noframes user to still view all content).
Please note: Don't tell me to only put noframes tags on the frameset page, I want noframes users to see content! The noframes tags as I've implemented them work perfectly and when I disable the javascript that forces the frameset to load, both the noframes and frames versions render exactly as I want them. however, I don't want a frames-supporting browser to load a page without the frameset.
Question is: How do I check for frames support from within that javascript?
Cheers
Anton
Thanks, I have actually tried something similar, but for some reason (as yet undetermined) it didn't work. I'll go back and debug my code a bit.
I'll test your suggestion, thanks a lot. I would still prefer if there was a standard js function that I could use, but it seems there is no such thing.
Cheers
Anton
I've tested your code above and it does work (BTW, I use Opera to test for noframes compatibility, since it allows you to switch frames support off). However, my version still isn't working. At least the concept is proven though, I'll just have to debug my code a bit further. If I don't get it right soon, I'll post back for your advice (unfortunately my javascript isn't very hot)
Cheers and thanks for the help.
Anton
Thanks for your input, I've got it working now.
Anyway, for anyone else interested, the final code (on the content page) that worked for me looks something like this:
<script>
var framesupport = true
</script>
<noframes>
<script>
framesupport = false
</script>
</noframes>
<script>
if (framesupport == true) {
currentURL=top.location.href;
contentIndex = currentURL.indexOf('?');
myContentURL=currentURL.substring(contentIndex+1, currentURL.length);
passpage = document.URL;
if (top.location==self.location) {
top.location.href="index.htm?"+passpage;
}
if (top.location!=self.location && contentIndex>-1 && myContentURL!=passpage) {
top.location.href="index.htm?"+passpage;
}
}
</script>
good point
However:
1 - If the browser doesn't support javascript either, this wouldn't be a problem since the script that forces the frameset to load wouldn't work anyway. So for browsers that support neither frames nor javascript - no problem. Only problem is with browsers that support js, but not frames. Browsers that support frames, but not js is a different thing altogether, though I can't imagine why anyone would do this?
2 - There are other browsers out there too. Opera for instance allows the user to switch off frames support. Mozilla (+ Firefox), Mosaic, Konqueror etc.
3 - As far as noframes support is concerned, I'm actually more concerned about search engine spiders than real people with browsers. Most people nowadays have frame support on their browsers. However, noframes have to be catered for to optimise search engine rankings and to cater for new technologies (how many cell phones have enough space on screen to display frames?)
Cheers
Anton