Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Autoload all frames?

Autoload all frames?
Thread Tools
Grizzled Veteran
Join Date: Jun 2001
Location: Seattle
Status: Offline
Reply With Quote
May 3, 2002, 07:08 AM
 
I've been trying to find information on loading all frames when one frame is opened. I think I could do this in JavaScript, but I'm not sure how to test if the frames are already loaded.
Basically I want to be able to have a link to something other than the main frameset and not lose the functionality of the navigation frames. And I don't want to define a new frameset for every permutation of all the frames. Any suggestions? Can you point me towards a resource? Anyone written something similar I could use to get started?
Thanks,
~BS
     
MrBS  (op)
Grizzled Veteran
Join Date: Jun 2001
Location: Seattle
Status: Offline
Reply With Quote
May 5, 2002, 04:41 AM
 
<bump>
anyone?
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Copenhagen, Denmark
Status: Offline
Reply With Quote
May 16, 2002, 07:26 AM
 
I believe that if you put this into the body of all the documents, it should do the trick (and if you want to reload more frames, just repeat with the proper changes). Please note that I had to divide the onloading command into two words, otherwise I wasn't allowed to post it - but it should of course be in one word.

Good luck,
Peter

<snip>

on load="parent.frames.the_name_of_the_frame_to_be_re loaded.document.location.reload();

</snip>
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
May 20, 2002, 07:35 PM
 
DISCLAIMER: I hate frames, and I don't endorse using them.

There, said it.

But on several occasions, I've had to use them due to plain stubbornness on the client's side. So I've come across a reasonably trouble-free solution to this. I say 'reasonably' because small issues like 'how do I link directly to a page' comes up, and you have to do a lot of jumping through hoops to get THAT to work. Sigh.

But here goes! Start with a 3 panel frameset like so:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>«!DOCTYPE HTML PUBLIC <font color = red>"-<font color = brown>//W3C//DTD HTML <font color = blue>4.01</font> Transitional//EN"</font></font>
<font color = red>"http:<font color = brown>//www.w3.org/TR/<font color = blue>1999</font>/REC-html401-<font color = blue>19991224</font>/loose.dtd"</font>»</font>

«html»

«head»
«meta http-equiv=<font color = red>"Content-Type"</font> content=<font color = red>"text/html; charset=ISO-<font color = blue>8859</font>-<font color = blue>1</font>"</font>»
«script type=<font color = red>"text/javascript"</font> language=<font color = red>"javascript"</font>»«!--

function loadURL() {
page = document.location.search;
if (page) { top.body.location.replace('/pages/'+page.slice(<font color = blue>1</font>)); }
}

<font color = brown>// --»«/script»</font>
«/head»

«frameset border=<font color = red>"<font color = blue>0</font>"</font> framespacing=<font color = red>"<font color = blue>0</font>"</font> rows=<font color = red>"<font color = blue>57</font>,*"</font> frameborder=<font color = red>"no"</font> on-load=<font color = red>"loadURL()"</font>»
«frame name=<font color = red>"header"</font> src=<font color = red>"(your header).html"</font> scrolling=<font color = red>"no"</font> marginwidth=<font color = red>"<font color = blue>0</font>"</font> marginheight=<font color = red>"<font color = blue>0</font>"</font> frameborder=<font color = red>"no"</font> border=<font color = red>"<font color = blue>0</font>"</font> noresize»
«frameset cols=<font color = red>"<font color = blue>120</font>,*"</font> border=<font color = red>"<font color = blue>0</font>"</font> framespacing=<font color = red>"<font color = blue>0</font>"</font> frameborder=<font color = red>"no"</font>»
«frame name=<font color = red>"panel"</font> src=<font color = red>"(your left panel).html"</font> scrolling=<font color = red>"no"</font> marginwidth=<font color = red>"<font color = blue>0</font>"</font> marginheight=<font color = red>"<font color = blue>0</font>"</font> noresize»
«frame src=<font color = red>"(your content).html"</font> name=<font color = red>"body"</font> noresize»
«/frameset»
«/frameset»

«body»You need frames, blah, blah...
«/body»

«/html»</font>[/code]

Notice the Javascript - you'll need that in order to link directly to pages within the site. Also note the names of the three frames - 'header', 'panel', and 'body'.

OK, now you'll need to create all the unique header pages. Say you had 6 sections within the site. Name your headers in a way that's easy to remember ('header-01', 'header-02', etc..) and make sure that's the title of each page («title»header-01«/title»).

Do the same for all the side panels - (e.g. ('panel-01-01', 'panel-01-02', 'panel-02-01', etc...) - just make sure you can remember which panel belongs to which section.

Now, for each of the content pages, you need to add a javascript to the «head» section. It could be embedded or linked to an external file. The code is:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
var defaultLocation = <font color = red>"http:<font color = brown>//your-site/your-page.html"</font>;</font>

function checkmenu() {

if (!top.window.frames.length&#0124;&#0124;!t op.window.frames['header']&#0124;&#0124;!top.window.frames['left']) {

top.location.href = defaultLocation;
return false;
}

else {

if (top.panel.document.title != checkmenu.arguments[<font color = blue>1</font>] && checkmenu.arguments[<font color = blue>1</font>] != null) {top.panel.location.replace(checkmenu.arguments[<font color = blue>1</font>] + '.html');}
if (top.header.document.title != checkmenu.arguments[<font color = blue>0</font>] && checkmenu.arguments[<font color = blue>0</font>] != null) {top.header.location.replace(checkmenu.arguments[<font color = blue>0</font>] + '.html');}
return true;
}
}
</font>[/code]

The first part of the code checks to see if the frameset is loaded and the correct frame names are present. If not, it should take you to the correct html page with the frameset code.

The second part then checks to see how many values you've passed to the function - if it's one, then only check the 'header' frame, or two then check both the 'header' and the 'panel' frames.

The last thing you need to do is add the 'on-load' condition to your body tag:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>«body .... on-load=<font color = red>"checkmenu('header-<font color = blue>01</font>','panel-<font color = blue>01</font>-<font color = blue>02</font>');"</font>»</font>[/code]

Replace the two parameters with the titles of the two frames you want to sync with.

Voila! Now whenever a page loads in the content frame, it will automatically check the top and left frames to make sure they are loaded as well.

The downside to this method? Lots of hard work and - potentially - incompatibility with older browsers, and browsers which have javascript disabled.

Use this as a quick'n'dirty fix, or if you feel inclined, improve on this code and send it back to me to show how it can be done better. I'd appreciate it!

NOTE: Because of UBB's poor HTML display, I've changes the < and > to « and ». Also, you may need to change '.html' to whatever suffix is best for your server. Also, UBB wouldn't let me put 'on-load' as one word - just remove the dash.
Computer thez nohhh...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:34 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2