Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Unload 1

Status
Not open for further replies.

alt131

Technical User
Dec 31, 2000
17
NZ
Have a site which uses iframes for IE and frames for the rest. Clicking on menu items loads external documents into iframes/frames (named content and content2). Sometimes a document is loaded into content, with content2 remaining 'blank', sometimes a different document loads into each of content and content2 - say text into content and a relevant pic into content2.

Problem is that when the document in content is changed, the document in content2 remains until such time as user selects a menu item that loads a document into that iframe/frame. This means that the document appearing in content2 is quite irrelevant to that being viewed in content. Thought I could fix the problem by writing an 'on unload' statement into the document in content that would cause it to reload the 'blank' document in content2 when it was unloaded. This seemed to be a way to conserve user resources rather than reloading a 'blank' doc in content2 everytime the menu is clicked.

Of course, cannot get it to work!!
Any suggestions for code - or a different process - would be most appreciated.
 
My first suggestion is to kill the whole frames setup you've got and just display your content on the page. What you're doing seems completely superfluous and arbitrary and will likely continue to cause more problems than its worth, both for you developing it and for your visitors using it. What is the reasoning behind using this frames setup in the first place?

If you're dead set on using this system, then my next suggestion is to launch both frames from the same link, eg:

<a href=&quot;javascript:go('url1','url2')&quot;>

function go(loc1,loc2)
{
top.content.location=loc1;
top.content2.location=loc2;
}
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
OK fair question - the user can maximise the iframes containing the content if they want to read it more easily. The system in place allows the user to see the nav system, start reading content while supplementary material down-loads, but can maximise content for easy reading when they want. If that doesn't make sense please visit to see - you need IE though - the frames version had not been uploaded.

Putting everything onto each page means that either the nav system goes to make real-estate for content, or the nav system is retained which makes reading less easy. Even worse, the user has to wait for the whole lot to down-load EVERYTIME they decide to have a look at a new page. Please don't lecture me on how caching speeds this up.

Couldn't get the script to work in NN and got worse when NN6.0 appeared so went to frames, 'cos while I detest them, at least they are supported. Am only a scripting-newbie but have been working on a script (based on some freebies) that will hide/show - and hopefully maximise the frames in the same way as I have done for iframe for IE.

I take your point about loading two docs - but that is the evil I am trying to avoid - heaps of users have slow machines, really low bandwidth - and still have incredibly busy lives they have to attend to.

Really appreciated your critical analysis - (always useful to as 'why do it at all' - now you see there is a point - any more suggestions?
 
You said you couldn't get it to load the blank document into the other frame, right? Well, using the above script would do that for you.

<a href=&quot;javascript:go('content.html','blank.html')&quot;>

Also, how would putting it all onto one page cause you to have to remove the nav menu? Don't you currently have it in a frame taking up space right now?

If you're using lots of large images which would take a long time to download, why not try creating thumbnails? Otherwise, what would be so huge of a bandwidth hog to justify putting parts of it in frames?
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Hi,

I followed your link and there is one thing I don't understand. If you are concerned about your visitors having slow machines and low bandwidth, why is your site so &quot;busy&quot;?

I agree with tanderson, I don't see how frames are helping you.

BTW, did you look at your page at 1024x768?

Bye.
Un fromage havarti en vaut deux.
 
Thanks guys.
tanderso THANKS for the script - sorry, but am a newbie - it looks like a link to me when I was looking for something that would be automatic. If its not a link, would you mind very much a short explanantion how to use it? Didn't think site was any busier than many others of same nature, but am trying to focus on having bandwidth applied to content, not layout or site 'admin' like nav. Re thumbnails - THANKS. THANKS for the reminder about larger resolution. I'll put it on the list before I go public.

RE layout did you not notice that you can maximise the content iframe so that it takes up the whole screen for easy reading - without having to open and then close a new window? (If not, please say so I know to put directions on it.) Response to your questions 'doesn't the nav currently take up space' is 'not all the time'.

But take your point, - frames are disliked and presumably iframes the same. I don't like frames either - can you suggest how to write a script that includes the maximise/minimise feature - WITHOUT using a new window everytime(which surveys say users dislike), AND when everything is written onto the same page (which you say would be best). PLEASE tell me how - I can't figure it out, but am keen to learn.

 
Yes, the above script uses a link. That link is meant to go into your nav buttons so that you can load whatever you want into both frames at once. It is no less efficient than trying to do an onUnload replacement of the doc.

Another way to do max/min is to use a layer. <div></div>
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
The menu system is a freebie applet and doesn't allow this. I plan to re-write it, but as it works in all versions other things are being given priority right now. As stated, an on unload statement seemed to be no less efficient which is why I plucked up the courage to ask for help with one.

Re layers - as I understand it they are not supported by IE or NS 6.0, which means a big chunk of users couldn't see the site - the reason I went to frames which are much more universally supported. However, to my understanding, the point of layers would be to carry an external file. This means that the info would not be written onto the same page which is what these posts quite clearly say I should do.

Would it be possible for someone to tell me how to put everything on one page - as recommended here - but also achieve the maximise/minimise function. Alternatively, if my understanding of layers is wrong, could someone be kind enough to direct me to a resource that explains them well and will show me how to use them crossbrowser? Attempts at an on unload statement are as unsuccesful as before - would really appreciate any advice on how to make it happen.

 
I would suggest against using Java applets. Use JavaScript instead. Layers (divs) are supported by both NS4+ and IE4+. You can fill the content of layers from either the page you create them on or from external pages. Try and for information on dynamic HTML.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Double-checking failed to identify anywhere on either of those sites that say that layers are CROSSBROWSER.

Have been unable to find anything on how to write everything onto one page and still load external docs and use the maximise/minimise funtion (using layers because they are crossbrowser) which is what I have been told to do.

Anyway, this was a javascript question about an on unload statement. Might be best if I make the post again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top