In our days web "pages" are not for just viewing and jumping from one link to another.
I’m a web developer and I’m creating lots and many times, huge applications for companies that want intranet enterprise applications.
Many times I face the need to cancel many browser events, including right and left click.
Consider that I have a list and next to each list item I have some add, edit, delete buttons.
(I’ll focus on the delete button) The delete button targets to a link page ->
(e.x.: http.…/item_delete.asp) that deletes the current list item from the database, but I want when the user clicks (left click event) on it, to display a confirmation message to ask if the user is sure about that item deletion.
To do that, I must cancel the left mouse click that user triggers over the delete link. Then it depends on users response (yes:delete - follow links href, no:do not delete - complete event cancel).
And just consider if the browser (the system typically) allows something to happen, then it may have a useful and logical usability for something.
By the way, in order to cancel the event:
HTML Code:
function cancelEvent() {
try {
var e = window.event;
if(!e) e = window.Event;
if(e) {
e.returnValue = false;
e.cancelBubble = true;
e.stopPropagation();
}
} catch(c) {}
return false;
}
For example:
<a href="something.com" onclick="Myfunction(); return cancelEvent()">.....
|