Tuesday 27 July, 2010

Check whether the pop up blocker is enabled or not

Use this snippet to detect if the client browser is using a popup blocker. If a one is detected, the script can then perform a different action. The sample uses an alert box to inform the user whether a popup blocker is present or not.


/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Casey Ryan :: http://www.ebooger.com */

function detectPopupBlocker() {
var myTest = window.open("about:blank","","directories=no,height=100,width=100,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,top=0,location=no");
if (!myTest) {
alert("A popup blocker was detected.");
} else {
myTest.close();
alert("No popup blocker was detected.");
}
}
window.onload = detectPopupBlocker;


1 comment: