- Michael Barton |
- JavaScript, Web Development |
- January 17th, 2010
I’m researching how to get pop ups to not be blocked using flash, and in that research, I found out how to check and see if a popup was blocked or not. It’s such a simple solution I don’t know why I haven’t consciously noticed it before. I’ve created many popups in the past, just never thought about how I would check if a popup was blocked.
The Solution
Using JavaScript, put something like this in your code:
1 2 3 4 5 6 7 8 | // this is sample code so replace // wurl = the url you want opened // wname = name given to the window so you can reference it again programmically // wfeatures = optionally you can give it scroll bars, make it resizeable, etc. var win = window.open(wurl, wname, wfeatures); if(win == null || typeof(win) == "undefined") { alert("Please enabled popups for this site to continue."); } |
That’s it! That’s all you need to do to test if someone has blocked your popup. Now you need to decide if it’s worth the hassle of working with popups and how to handle when a popup is blocked.
The three simple ways around using popups are:
CONTINUE READING

