?
Solved

Using onload with a frameset

Posted on 1998-08-25
5
Medium Priority
?
1,061 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

777 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