Chris Conway Chris Conway - 4 months ago 14
Javascript Question

Popup detection before user logs in

Is there a good way to determine if a person has a popup blocker enabled? I need to maintain a web application that unfortunately has tons of popups throughout it and I need to check if the user has popup blockers enabled.

The only way I've found to do this is to open a window from javascript, check to see if it's open to determine if a blocker is enabled and then close it right away.

This is slightly annoying since users who do not have it enabled see a small flash on the screen as the window opens and closes right away.

Are there any other non-obtrusive methods for accomplishing this?

Answer

Read Detect a popup blocker using Javascript:

Basically you check if the 'window.open' method returns a handler to a newly opened window.

Looks like this:

<script type="text/JavaScript" language="JavaScript">
 var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
 if(mine)
    var popUpsBlocked = false
 else
    var popUpsBlocked = true
 mine.close()
</script>
Comments