'Cancel onclick event in IE5

I want to cancel inline onclick event

<p id="demo" onclick="alert(1234)"></p>

in certain condition, so I am using a global onclick event to conditionally overwrite this event.

this.document.attachEvent('onClick', function(e){
        if(--some condition--){
            --code to cancel onclick event--
        }
});

the question is what to write in --code to cancel onclick event--.

I have tried e.preventDefault(); e.cancelBubble = true; return false; however nothing works.

Please notice that the browser need to be IE5.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source