Event handler onload
(Bubbles: No, Cancelable: No) terjadi ketika suatu objek telah menyelesaikan proses muat, contohnya ketika halaman dokumen HTML pertama kali dimuat.
Berikut contoh meregister event handler onload
via 'inline model':
<BODY ONLOAD="alert('Welcome..');document.body.style.backgroundColor='red'">
Berikut contoh meregister event handler onload
via 'traditional model':
<BODY ID="bodyID">
<SCRIPT TYPE="text/javascript">
function HandleEvent()
{
alert("Welcome..");
document.body.style.backgroundColor="red";
}
document.body.onload=HandleEvent;
</SCRIPT>
Berikut contoh meregister event handler onload
via DOM:
<SCRIPT TYPE="text/javascript">
function HandleEvent()
{
alert("Welcome..");
document.body.style.backgroundColor="red";
}
window.addEventListener("load", HandleEvent, false);
</SCRIPT>