Forum Moderators: open
The main site has frames (I know; yuck!)
---- When the page loads "onload=checkFrames()"
function checkFrames() {
// alert("parent.frames.length = " + parent.frames.length);
if(parent.frames.length <= 1) {
// Fix for Deep-link to our page with no Nav bar frame
parent.location = "../fr_blank.htm?" + self.location;
}
else if(parent.frames[0].location.href.indexOf("/nav.htm") == -1) {
// Fix for Link to our page with foreign frame
parent.location = "../fr_blank.htm?" + self.location;
}
}
----- the page fr_blank.htm then does onload=myOnLoad() ... -----
function myOnLoad() {
myRef = parent.location.search;
if(myRef.length > 0) {
parent.frames[1].location = myRef.substr(1);
}
}
---- ... to bring back the navigation frame, but this is really messy, and does not allow browsers to back up, etc.
Is there a better way to fix this (without re-doing minus frames)?
Thanks
William
There are a number of improvements possible:-Kaled, I understand what you said, more or less, but I'm not sure which parts of which scripts the fixes go into. (newbie javascripter, sorry)
1) Use location.replace(href); to allow back button to work.
2) I prefer 'fr_blank.htm?' rather than '../fr_blank.htm?'
3) I prefer if (top!=self) to test for the existence of frames.
4) I prefer top.fr_main rather than top.frames[1]Kaled.
Place this in the frameset. This assumes the main frame is called "fr_main".
function myOnLoad() {
var page = top.location.search;
if (page) {top.fr_main.location.replace(page.substr(1));
}}
In your original code, there appears to be an effort at breaking free from alien frames - I have not included code to do this. When I experimented with this some years ago, I could find no method that worked reliably across all browsers but there is probably a simple way to do it.
You should be aware that using frames in this way leads to ugly urls and fixed titles (being that of the frameset). There is a better way but it is much more complex and would probably result in several heart attacks amongst WW purists.
Kaled.
Thanks. One really difficult thing: I have either 1 or 2 AdSense ads on the garden pages, and I think their items count as frames...
I gave the code a good fiddle yesterday, and only succeeded in getting the pages (a) not to update the Nav bar, or (b) to go into a tight load/reload/reload loop.
Testing on Mac OSX with Safari 2.0.2 and Firefox 1.5
Loops are potentially a problem for this sort of thing but since I don't use a Mac I cannot comment on your browsers.
Onload in a frameset may be a problem - I've never used it. You could try ignoring onload in favor of placing the javascript between the </frameset> and </html> closing tags - it might be ok.
You could consider using document.write() to create (part of) the frameset. You can also set the page title too.
Kaled.
I will now do a re-design of the site to eliminate the frames, and leave the navigation stuff embedded on EVERY page. Not quite so elegant, but definitely more reliable.
The garden pages are built by a custom compiler (written in Macromedia Director) which takes Filemaker Pro output and uses a special page template to build all 450+ pages, which I then upload.
So, once I get a single page working right, I can make a template from it and then rebuild the whole site. Time consuming, but better than the mess I have now.
Thanks very much for your time.
You are presumeably using an asynchronous request, so you can put your message hiding statement(s) inside a callback function that is called by the onreadystatechange event
[jibbering.com...]