I’ve created a JS Fiddle at http://jsfiddle.net/Vcftv/2/ that illustrates the problem.
I have some promos/modules which I’m turning into big target links via JS. Basically, the entire promo/module becomes a link, not just a tiny child anchor/html text link. You can click anywhere on the promo/module to follow the child href.
I need some of these to open the href in a new window – I’m just hooking into the target attribute for this. If the link has a target attribute, that means to pop a new window. I’m getting the problem of multiple windows opening when I do some testing and click-throughs.
In the JS fiddle, the first module follows the href in the window. The second and third should pop new windows. They’re not quite working right, sometimes one will work fine, but when you close the new window and click the link again it’ll pop the url in 2 new windows.
Anyone have any ideas?
The problem is that every time a user hovers over the div, your attaching another click event listener! See my edit and notice in the console how often the ‘attaching click listener’ call is made.
Kelly’s solution is far simpler, but the problem with your implementation is as I’ve described. This edit fixes the problem.