views:

233

answers:

1

Is there a set of best-practices or advice to avoid pop up windows being blocked by the different browsers pop-up blockers?

By pop-up I mean windows created by either window.open or window.showModalDialog methods.

Thanks a lot

Edit:

I do not plan to bypass the pop-up blockers with hacks. I came to this while developing an OAuth authentication flow purely in javascript and I needed to show the user the "grant access" window (I couldn't avoid the pop-up blockers and had to use a different approach).

+4  A: 

The general rule is that popup blockers will engage if window.open or similar is invoked from javascript that is not invoked by direct user action. That is, you can call window.open in response to a button click without getting hit by the popup blocker, but if you put the same code in a timer event it will be blocked. Depth of call chain is also a factor - some older browsers only look at the immediate caller, newer browsers can backtrack a little to see if the caller's caller was a mouse click etc. Keep it as shallow as you can to avoid the popup blockers.

dthorpe