A problem was encountered today when testing the 69th page of the JavaScript Dom Programming Art (2nd edition). The expected effect should be to click the link does not jump to the current page, but also pop up a window. But the result is a page jump. The code looks like this:
after a query and search, it is found that the problem is " return false; " does not work successfully, so there is no default behavior to unlink the link, leaving the visitor out of the current window. If the code is written and its success is communicated, the result is the effect that you want to achieve.
So what's the problem? (see URL: A tag's cancellation default behavior-segmentfaulthttp://segmentfault.com/q/1010000002993720)
Here's a little demo.
Well, the question is how to figure it out, but how to solve it? Online said are said to use Event.preventdefault (); some say more detailed is to distinguish between IE browser and non-IE browser, they block the default behavior has some differences, ie should be window.event.returnValue = = false; Plus Event.stoppropagation (); block bubbling behavior. However...... I tried and tried, and there was no successful implementation of canceling the default behavior.
so, for the time being, I didn't find a way to successfully complete the unlink default behavior while separating the JavaScript, and now it's only possible to write the onclick= in the a tag . "" .
It was a sad ending (╥╯^╰╥)
JavaScript unlink default behavior problem