Master Javascript by Typing PART III
Page 2Launch your Text Editor, type the above given code & save as sixth.html
(or any other name you prefer). Now view the file that you created in
browser & initially while the page loads you will see the preloader
DIV. Once the page is completely loaded the preloader disappers and the
original page is shown.


Here there are 2 Div's used d1 and d2. d1 contains the preloader message and it is initially set ina visible mode (check out the style visibility:visible in the code above). d2 is the container which hold all the other contents of the website and initially it is set hidden(check out the style visibility:hidden in the code above). So when the page is loading the viewer is shone only the first div. The rest of the page gets loaded in invisible mode.
Then there is an event handler onLoad in the Body tag and it will get activated when the page is fully loaded. When this event is fired it calls a function called shPage(). In shPage() we are using the style.visibility property to toggle the visibility mode of d1 & d2. The first line of code in that function makes the preloader div (d1) hidden and sets d2 into visible mode.
Reference :
- onLoad
If you want any function or piece of javascript code to get executed when a page is loaded into the browser window then you can use this event handler.
- onUnload
This event handler is the exact opposite of the event handler onLoad and is activated when an HTML page closes or the user leaves a page to another webpage.
That's it guys/gals, we are concluding our third edition of this paper on javascripting here. Will be back next month with the rest of the available event handlers.
.
