views:

120

answers:

1

I have a problem that I have been trying to figure out and haven't been able to get past it because Chrome/FireFox/IE do not publicly publish their "rules" for pop up blocking when it comes to JavaScript, Flash, etc. I am trying to trigger a window.open() when a user clicks anywhere on page. I've tried this:

document.onclick = window.open("http://msn.com");

But all 3 browsers are blocking the popup, even though it is a user interaction.

+2  A: 

If the user is blocking pop-ups, it's because they don't want popups like yours to appear as a response to their user interactions. If a popup (as opposed to something more sophisticated such as making an otherwise hidden div appear) is what you really must have, then inform the user that they need to enable popups to interact with your site (I've seen a few sites do that, that annoys me and I count it as a big black mark against the site that prompts me to look for their competitors and alternatives, but if there's no real alternative I'll grit my teeth and temporarily re-enable popups in such cases). (But, do consider that annoying users is not a way to win their hearts and minds, so do look for nicer alternatives!-).

Alex Martelli