View Full Version : Onload in Frames
peterinwa
03-30-2003, 12:47 AM
I've never used nor really understood onload, so please speak to me like I'm a 4th grader. Maybe 3rd.
I want to display a simple image while my database is being loaded from a .js file, afterwhich I want to create a page (which uses the database) to replace the simple page which was orginally diaplayed.
I'm wondering if in that first simple page I can use an onload command to create the second page AFTER the database is loaded. So my question is what does onload mean? In frames, does it cause the action after the data for every frame is loaded?
Or does it cause the action after just the Frame the onload command is in is loaded?
Also, what is the syntax to call a function on onload?
Thanks, Peter
Mhtml
03-30-2003, 02:18 AM
Ok well onLoad will process any command you tell it to when the page has finished loading..
So for example you could display your image..
<img src="loading.gif" id="myImg">
And have your database loading, when it's loaded you'll want to get rid of the image..
function hideImage(){
myImg.style.visibility = 'hidden'; // Turn the image invisible!
}
So once your js database has loaded the page should be completely loaded, you can now call the onLoad event!
onLoad="hideImage()"
That will call the hideImage() function we wrote earlier and hide the image, but only once the page is fully loaded.
peterinwa
03-30-2003, 02:38 AM
Thanks, but I'm still confused.
My JS code creates a page image.html. It takes a while as a lot of data has to be loaded into the page from a .js file.
So I already have a page image.html which is a dummy... just a gray background that shows up until the actual page is created on the fly.
You see this dummy page for a longer or shorter period of time depending on how long it takes to create the new page. Once it's created, it steps on itself.
This is all fine; I can just make the temporary, dummy page say "Please wait while the data is loading."
But I tried it with a huge database to load and instead of seeing the dummy page I linked from for a long time image.html didn't show up... the screen displayed the previous page during this process... then the image.html flashed then the newly created image.html appeared.
So I'm trying to get the original image.html to stay on the users screen until the new image.html is created and steps on it.
At the end of my code to create the new page, I call a function to do so. I thought maybe if I called that function with onLoad it wouldn't happen until the page was completely loaded/created. But I guess that's kinda automatic anyway since I have this function call at the very bottom of all the coding to create the page.
Don't know if this makes any sense. What I am writing OR what I am doing!?!
Thanks again, Peter
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.