?
Solved

Using onload with a frameset

Posted on 1998-08-25
5
Medium Priority
?
1,076 Views
Last Modified: 2013-11-19
I'm using a frameset tag with an "onload" and the function name in the onload is not being called until I load that page for the second time.

In this example I have a page with multiple frames, within one of those frames I'm loading a new page which has the frameset tag and the onload that I'm having problems with.  This new page (tree.html) is adding two more frames within an existing frame.

The frameset in the top most page looks something like the following (the onload=loadWin() in this page works fine, and is located in the lib.js file):

-----------------------------------------------------------

<SCRIPT LANGUAGE="javascript" SRC="../../../js/lib.js"></SCRIPT>

 
<frameset border=1 frameborder=0 framespacing=0 onLoad=loadWin() cols="22,*,428">

  <frame noresize scrolling="no" src="../../../js/blank.html" name="strip">
  <frame noresize scrolling="no" src="../../../js/blank.html" name="popwin">

  <frameset border=1 frameborder=0 framespacing=0 rows="60,*">
    <frame noresize scrolling="no" src="../../../js/blank.html" name="nav">
    <frame noresize scrolling="auto" framespacing=0 src="../../../js/blank.html" name="main">
  </frameset>

</frameset>

-----------------------------------------------------------

The file that's giving me all the trouble is being loaded in the second frame with the following script.

      window.popwin.document.location="../tree.html";

the tree.html file looks like the following:

-----------------------------------------------------------
<HTML>
<HEAD>

    <SCRIPT language="JavaScript" src="info.js"></SCRIPT>
    <SCRIPT language="JavaScript" src="proc.js"></SCRIPT>
    <SCRIPT  language="JavaScript" src="../../js/browser.js"> </SCRIPT>

    <frameset border=1 frameborder=0 framespacing=0 onload="createBrowser('Draft')" rows="45,*">
      <frame noresize scrolling="no" src="../../js/blank.html" name="poptp">
      <frame noresize scrolling="auto" framespacing=0 src="../../js/blank.html" name="popmain">

    </frameset>

  </HEAD>
</HTML>
-----------------------------------------------------------

Now, my problem is that the createBrowser() function (located in the browser.js file) is not executed until that page (tree.html) is loaded for the second time.  There is a HREF tag in one of the other frames that I'm using to load the popwin frame with the new page.  I understand that I could load the tree.html file when I create the frameset but I only want to load that page if the user makes a selection.

So, my question is, why is the script acting this way and what can I do to make sure the onload will work correctly the first time the page is loaded.

thanks,

Vanfleet
0
Comment
Question by:vanfleet
  • 4
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 800 total points
ID: 1269640
Solution 1: Do not put the onLoad scripts in the js file - it loads in whatever order, totally uncontrollably and is not covered by the onLoad which can trigger long before the js file(s) is(are) loaded.

Solution 2. Set a flag to false outside the js file and to true in the bottom of the js file and don't attempt to use any scripts until this flag is true.

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269641
PS: The reason it works the second time is that the js file has been cached by then

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269642
PPS: A bug in Netscape 3.x will trigger the onLoad before all pages have been loaded - another reason to use flags if your script are dependant on pages having been loaded or not.

Michel
0
 

Author Comment

by:vanfleet
ID: 1269643
When I put the function called in the onload in the same file (outside of the js file) it seems to work fine.  I should note here that I had to put the function at the top of the page before the script tags with the js files.  If I put the function after the other script tags I had the exact same result as before.  I'm not sure why, that page has got to be entirly loaded by then.

Thanks for your help,
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1269644
I have noticed that especially Netscape 4 tries to be 'clever' and 'nice' to you and tries to load as much as possible in as clever a way it can - I would not be surprised that if Netscape suspects that the .js file might contain something useful, it will delay execution of other things.

I have a problem with a polling script that tries to load one image from several servers. The property image.complete should be set be either onLoad/onError or onAbort but netscape 4 says, oh, what the heck, let's set it immediately we have tried accessing the image instead of when one of the above events happened. This is not the only time I have seen this kind of behavior.

The really big problem is when they fix it in the next version and your script might not work anymore because you were relying on a 'bug'...

Happy to hear you solved your problem.

Dooi,

Michel


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question