[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Using onload with a frameset

Posted on 1998-08-25
5
Medium Priority
?
1,063 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to implement server side field validation and display customized error messages to the client.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

649 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