Sunday, March 04, 2007

Popup Blocker Detection

Popup Blocker Detection

Many a times our webpage would be needing to open some information in child popup windows. And hence due to the large amount of pop up window nuisances, we have a lot of popup blockers (free and shareware) in the market. Hence it has become mandatory for us to have a code that detects and advises the user regarding the significance of our website to allow having the ability to open popup windows.

The code trick is quite simple. It just depends on the return value of window.open() in JavaScript. You can put the code in the top of the webpage itself within <script></script> tags.

var objTestPopupWindow = window.open('about:blank', '', 'width=0,height=0");
if (!objTestPopupWindow)
{
    alert ("Whoosh! There is an active popup blocker in this web browser. Please consult your browser or popup helper documentation on how to allow this site to use popups");
}
try
{
   objTestPopupWindow.close();
}
catch (e)
{
}

No comments:

[Imported from Blogdrive]Online Virus Scanners

Online Virus Scanners Virus Scanners are no longer difficult to install, tedious to configure. There are easy to use Online Virus Scanne...