<script>
function confirmDel(evt)
{var con =false;
con=confirm('Do you really want to remove this purchase?.');
if(con)
{
return true;
}else
{
event.preventDefault();
}
}
</script>
my html
<a title="View Log" onclick="return confirmDel(this);" href="index.php?mod=tech_support">delete</a>
above code works fine in chrome browser but fails in Mozilla .
but when i use return false instead of event.preventDefault(); it works fine in both.
can anyone explain why this happens
The problem is with
event.preventDefault(). The event you’re passing isevt, notevent. You have to use:event.preventDefault()works in Chrome because it mimics old IE behavior for backwards compatibility (just like it also hasinnerText).In old IE, the event object was
window.event. So callingevent.preventDefault()calls the global event object, which works in Chrome and IE, but not Firefox which doesn’t implement this non-standard behavior.