Friday, December 28, 2012

onmousedown

Event handler onmousedown (Bubbles: Yes, Cancelable: Yes) terjadi ketika tombol mouse dalam kondisi tertekan. Event handler ini valid untuk hampir semua elemen.

Berikut contoh meregister event handler onmousedown via 'inline model':

<A HREF="#" ONMOUSEDOWN="alert('Halo saya event handler')">Visit to X.com</A>

Berikut contoh meregister event handler onmousedown via 'traditional model':

<A HREF="#" ID="anchorID">Visit to X.com</A> <SCRIPT TYPE="text/javascript"> function HandleEvent() { alert('Halo saya event handler!'); } document.getElementById("anchorID").onmousedown=HandleEvent; </SCRIPT>

Berikut contoh meregister event handler onmousedown via DOM:

<A HREF="#" ID="anchorID">Visit to X.com</A> <SCRIPT TYPE="text/javascript"> function HandleEvent() { alert("Halo saya event handler!"); } var anchorElem=document.getElementById("anchorID"); anchorElem.addEventListener("mousedown", HandleEvent, false); </SCRIPT>