Results 1 to 12 of 12
Thread: popup blocker detect
-
02-22-2006, 06:04 PM #1Web Hosting Master
- Join Date
- Mar 2004
- Posts
- 1,303
popup blocker detect
I've found this nice javascript which detects browser with popup blocker enable.
http://www.ezdevcomponents.com/ezdev/art.aspx
Hope someone find this helpful.
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
<script language="javascript">
//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;
}
</script>
<html>
<body onload="openWindowCheck('page1');" style="margin:0">
<style>
#msg{
background-color:#ccffff;
height:200;
width:200;
font-family:verdana
}
</style>
<div id="popupmsg" style="visibility:hidden;text-align:center;">
<div id="msg" style="">
^<br>
^<br>
^<br>
^<br>
It appears you have your popup blocker turned on for this site.
<br>
<a href="javascript:closeIt()">close</a>
</div>
</body>
</html>
0
-
02-22-2006, 06:08 PM #2Web Hosting Master
- Join Date
- Mar 2004
- Posts
- 1,303
here is the shorter one
http://www.visitor-stats.com/article...up-blocker.php
There must be many scripts out there for this same purpose.0
-
02-22-2006, 10:22 PM #3Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 1,767
<script>
if (w != window.open("/whatever.html")) alert("Turn off your popup blocker!");
</script>0
-
02-23-2006, 12:38 PM #4Newbie
- Join Date
- Feb 2006
- Posts
- 11
nice scripts...nice to know there are ppl who think about popup blockers...
0
-
03-24-2006, 03:05 AM #5Newbie
- Join Date
- Mar 2006
- Posts
- 5
This is useful, good post!
0
-
04-04-2006, 04:16 AM #6Newbie
- Join Date
- Nov 2005
- Posts
- 13
Thanks a Ton, I feel that the post was very useful
0
-
05-14-2006, 08:09 PM #7Newbie
- Join Date
- May 2006
- Posts
- 13
Very usefull. Nice one.
0
-
07-17-2006, 03:39 AM #8Web Hosting Master
- Join Date
- Nov 2003
- Posts
- 691
EDIT: Nevermind, didn't realize this was an old thread.
0
-
05-19-2008, 11:45 AM #9Newbie
- Join Date
- Nov 2007
- Location
- England
- Posts
- 13
Very nice tutorial Thank you
0
-
08-19-2008, 11:30 AM #10Newbie
- Join Date
- May 2007
- Posts
- 16
Ah the one liner is very useful. Thanks
0
-
08-20-2008, 03:35 PM #11Newbie
- Join Date
- Jul 2008
- Posts
- 16
there are many tools or links out there to enable this.
http://www.visitor-stats.com/article...up-blocker.php
this is a good one also0
-
09-11-2008, 09:09 AM #12Newbie
- Join Date
- Sep 2008
- Posts
- 12
IE7 has a default popupblocker managed by reg @
Key: HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_WEBOC_POPUPMANAGEMENT0