Today, while creating some javascript popup I had a condition in which I place onclick function on body tag. I had an other button which also implement onclick. So the code looks like as follows
1: <body onclick="disappearPopup()">
2: <a href="#" onclick="ShowPopup()">Show me</a>
3: </body>
So, what happen is whenever link is click the body clicked even called automatically. Practically speaking, we need to cancel the body onclick even each time we click the link click.
And for that I write the following code on click of the link
1: if (window.event) {
2: window.event.cancelBubble = true;
3: }
4: else {
5: e.stopPropagation();
6: }
And it works ....