Forum Moderators: open

Message Too Old, No Replies

Javascript, functionality before page load

         

shadct

5:09 am on Jun 3, 2008 (gmt 0)

10+ Year Member



hi everyone,

I need a functionality to be executed before the page loads.is it possible?

Regards,
Shalini.

httpwebwitch

5:28 pm on Jun 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi shadct, welcome to WebmasterWorld!

Please review this complete list of built-in Javascript Events [w3schools.com]. Each of these is a trigger to which you can attach a "listener"; in other words, it's the "when" to which you may attach a "what".

For example, if I want something to happen when the user loads a page, do this:

window.onload = function(){
alert('you just loaded a page!');
}

Technically speaking, the event is "load", and the listener to that event is "onload". Listeners always start with "on".

You aren't limited to the built-in events; you can define your own, or use a script library to add useful events like domready [docs.mootools.net].