Demonstrating Default Event Cancellation V2...

This is the main paragraph

[ Previous ] [ Next ]

The above links point to my weblog. But the nullify event has been assigned to both of them, so when they are clicked the default action will be cancelled and they will do nothing...

Tom Wright, 02/03/2005 23:59

The Code

window.onload = function() {

		document.getElementById('NextTextLink').onclick = nullify;
		document.getElementById('PrevTextLink').onclick = nullify;
		
} //end of the function  



function nullify(evt) {
   if (!evt) evt = window.event; // define the event object for MSIE

   if (evt) {
     if (evt.preventDefault) {
       evt.preventDefault(); // cancel the default event Opera, Mozilla
       evt.stopPropagation(); // this will stop the method bubbling out
     }
     else {
       evt.cancelBubble = false; // stop bubbling on MSIE
       evt.returnValue = false; // cancel the default event MSIE
     }
   }
}