Forum Moderators: open

Message Too Old, No Replies

Messy hack

         

donelson

2:01 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



We have a gardens guide website. Visitors usually enter via a Google listing of a particular page / garden, e.g. search for: york gardens guide

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

kaled

5:21 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are a number of improvements possible:-

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.

donelson

5:54 pm on Nov 6, 2005 (gmt 0)

10+ Year Member



There are a number of improvements possible:-
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.

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)

kaled

11:41 pm on Nov 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Place this in the <head> of the page. Ditch the onload assignment - this will be quicker.
if (top==self) location.replace("fr_blank.htm?" + self.location.href);

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.

donelson

12:28 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



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

kaled

2:43 pm on Nov 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Adsense should not be an issue.

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.

donelson

2:46 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



Thanks. I'll give it a go, one baby step at a time!

donelson

7:07 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



Didn't work at all. Went into a messy loop.

kaled

7:18 pm on Nov 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Post your new code.

Kaled.

donelson

8:37 am on Nov 8, 2005 (gmt 0)

10+ Year Member



Kaled, no thanks. The issue is much more complicated, due to the whole way the site is set up. If I had known that the frames would be such a mess for navigation, I would have never done them in the first place.

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.

kaled

11:17 am on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If your sole objective is to keep negate the need to duplicate navigation, you can do this quite easily with an <iframe>. The navigation area will scroll but you can use css position:fixed to lock it in place in both Opera and Firefox. IE will catch up eventually.

Kaled.

whoisgregg

5:31 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



custom compiler (written in Macromedia Director) which takes Filemaker Pro output

Wow, finally someone else who does sites using Filemaker Pro as part of their workflow. :D

donelson

6:17 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



Yes, but we export the data as tab-delimited fields, then process it with a set of MM Dir scripts

[edited by: jatar_k at 6:32 pm (utc) on Nov. 8, 2005]
[edit reason] no urls thanks [/edit]

donelson

7:23 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



... through an HTML template, directly into web pages, which we then upload. The compiler also outputs files suitable for the companion book as well.

Bernard Marx

7:35 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onload only works for the window, images and occasionally frames.

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...]