Web Hosting Resources, Forum, FAQ, Directory
Home
Hosting
$1.99 Domain
Reseller
Add URL
Sunday
Login
Username:
Password:
Lost Password?
Register now!
Main Menu
Home
Hosting Article
Submit
Blocks
Archive
List
Tag list
Search
Hosting TAG
Contact Us
Hosting News
Hosting FAQ
Private Messaging
Extended Profiles
Search
Advanced Search
Send by email
Email address *
Title *
Content *
Detecting Popup Blockers Detecting Popup Blockers [2/16/2005, Geo Hilal] With all the new spyware and unsolicited advertisement users are becoming more aware of the problems they can cause on their PC. Many users have installed popup blockers by downloading a free one form the internet or updating to service pack 2. These blockers have been great at eliminating most of the annoying things that come along with the popups. Unfortunately there is still a legitimate need to have windows popup. A user may experience a site as broken because their blocker did not allow a valid window to open. One way to do this is to check if javascript can access the handle to the window that was opened. I have tested this technique with these popup blockers, IE (SP 2), FireFox, Yahoo, and Google and it seems to work. Below is the sample code. The key to this working is to keep track of the window handle and check if javascript can access it. View sample //set object to hold windows var oWindowsT = new Object(); function openWindowCheck(pageId) { //open window openWin(pageId); //check if the window opened setTimeout("checkOpen(\"" + pageId+ "\")",1000); } function checkOpen(pageId) { try { if ( (!oWindowsT[pageId]) || (oWindowsT[pageId].closed) ) { //handle code how ever you want var elem = window.document.getElementById("popupmsg"); elem.style.visibility = "visible"; } else { var elem = window.document.getElementById("popupmsg"); elem.style.visibility = "hidden"; } }catch(e){ //if unable to read var show message } } function closeIt() { window.document.getElementById("popupmsg").style.visibility = "hidden"; } //open a window function openWin(pageId) { switch (pageId) { case "page1": //set window properties var sPar = "width=500,height=500"; handle = window.open("http://cnn.com",pageId,sPar); break; case "page2": //add code for another id //handle = window.open(sURL,page,sPar); break; default: } //add handle to window object holder oWindowsT[pageId] = handle; } #msg{ background-color:#ccffff; height:200; width:200; font-family:verdana } ^ ^ ^ ^ It appears you have your popup blocker turned on for this site. close more... http://www.powerhoster.com/domainhosting/modules/article/view.article.php/c1/2325
* = Required
© 2001-2007
Power Hoster