Click here to Skip to main content
16,021,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends

I am trying to detect if there is popup blocker enabled in browsers. I got it except for Google chrome.

I'm using the code given below:
JavaScript
function detectPopupBlocker()
{
    var windowRef = window.open("Add.aspx","","directories=no,height=100,width=100,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
    if (!windowRef || typeof windowRef.closed == 'undefined')
    {
       alert("Popup is blocked in your browser, please turn off popup blocker before joining game");
    }
    else
    {
       windowRef.close();
    }
}
window.onload = detectPopupBlocker;


If any one knows how to detect popup blocker in chrome, please help me.

Thanks in advance
Nidhin
Posted
Updated 1-Jun-10 21:12pm
v2

Please Check this i hope i will run in all browser
C#
function openPopUpWindow(format)
           {

               var win = window.open('ReportView.aspx?format='+format,'ReportViwer','width=920px,height=720px,left=50px,top=20px,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=1,maximize:yes,scrollbars=0');

               if(win == null ||  typeof(win) == "undefined" || (win==null && win.outerWidth == 0)  ||  (win!=null && win.outerHeight == 0)  || win.test == "undefined")
               {
                   alert("The popup was blocked. You must allow popups to use this site.");
               }
               else if(win) {
                   win.onload = function() {
                       if (win.screenX === 0) {
                           alert("The popup was blocked. You must allow popups to use this site.");
                            win.close();
                       }
                   };
               }
           }
 
Share this answer
 
nidhinp25 wrote:
I got it except for Google chrome.


These thread will help you out: Detect blocked popup in Chrome[^]
detect when the Chrome Browser has popups blocked [^]

Though:
The code that you have shared across is not of a Popup. It's a new window. Strictly speaking, there is a difference between a Popup and a new window.

Read here:
Popup[^] Vs New Window[^]

Further, this article would clarify more:
What gets blocked - Popup or NewWindow?[^]
 
Share this answer
 
Like this.
C#
function openPopUpWindow(format)
            {

                var windowRef = wwindow.open("Add.aspx","","directories=no,height=100,width=100,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");

                windowRef== null ||  typeof(windowRef) == "undefined" || (windowRef==null && windowRef.outerWidth == 0)  ||  (windowRef !=null && windowRef.outerHeight == 0)  || windowRef.test == "undefined")
                {
                    alert("The popup was blocked. You must allow popups to use this site.");
                }
                else if(windowRef) {
                    windowRef.onload = function() {
                        if (windowRef.screenX === 0) {
                            alert("The popup was blocked. You must allow popups to use this site.");
                             windowRef.close();
                        }
                    };
                }
            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900