detect popup blocker

I need a way to detect if the user is useing a popup blocker, and if so alert them to turn it off.  i dont know which way would be better to open a test windows and then somehow check if its open or if there is any other way..?
LVL 2
mattaustinAsked:
Who is Participating?
 
jaysolomonConnect With a Mentor Commented:
var nw = window.open("somewhere.asp","newWin");
if(!nw){
  alert("Please turn off that pop up blocker so i can show you something");
}


Maybe this wil work
0
 
devicCommented:
hi mattaustin,

like this :)
=================
<script language = JScript.Encode>#@~^6wAAAA==@#@&\CMPaWw!w,xPSkUNKh ^Kx0b.:vBfK~zW!P4l-+~C,wGw!2P(VG^0+D_w      Zsk1V,rF,k6PXKE,4l7+~r"P/C      m+^~k6PxKOv#p@#@&kW`Z2Kw;w*Ak      NGAcmWUWbDh`EWMlU0VHgB*@#@&r0vwGw!wbC^+DDcBkYDmrLtDPslU"vb@#@&nVknPmVn.D`BCUHhCX,r,NG      Y'BP(+^r\PzW!~~^4+lDnDeB#@#@&iUsAAA==^#~@</script>
0
 
devicCommented:
oops sorry for mistake:
==============
<script language = JScript.Encode>#@~^8QAAAA==@#@&\CMPaWw!w,xPSkUNKh ^Kx0b.:vBfK~zW!P4l-+~C,wGw!2P(VG^0+D_w      Zsk1V,rF,k6PXKE,4l7+~r"P/C      m+^~k6PxKOv#p@#@&kW`Z2Kw;w*`hbx[GSRmGU6k.:vv6DC      3^XgE#)@#@&b0cwKw;2*      l^nDD`BkO.lbo4Y~:CUeBb8@#@&+^/n~PlVn.D`vl      zSlz,k,NW      Y'vP(+sk7+~zKE~,^tlY.ZB*8@#@&cU4AAA==^#~@</script>
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
devicCommented:
monday ;(
this what i mean :)
=========================
<script>
var popup = window.confirm('Do you have a popup blocker?\nClick OK if you have OR Cancel if not');
if(!popup){window.confirm('frankly?')}
if(popup){alert('straight man!')}
else {alert('anyway i dont\' belive you!')}
</script>
0
 
BustaroomsCommented:
jay,  i currently use something similar to your version

i put this at the beginning of my page

//open the test popup window for popup blocking detection
 var mine = window.open('','','width=1,height=1,scrollbars=no');
 if(mine)
    var popUpsBlocked = false
 else
    var popUpsBlocked = true
 mine.close()

then later on on my page
if(popUpsBlocked)
  alert('We have detected that you are using popup blocking software.\nIn order to access...');




end users of my pages would email my company all the time and half the time our response would be "You will need to turn off your.....".    I have implemented this on certain pages and have not had any of those emails from end users using those pages....so its going good so far
0
 
BustaroomsCommented:
just to let you know that it does work
0
 
jaysolomonCommented:
Thats good Busta.

I haven't really thought much about the pop up blockers.

Nice script, keep your good code a coming ;)



@devic
Why use IE only stuff?
0
 
devicCommented:
@ jaysolomon,
what do you mean?
0
 
jaysolomonCommented:
>>JScript.Encode

IE only
0
 
mattaustinAuthor Commented:
i guess i accepted the answer a little early , it dosn't seem to sop the google toolbar popup blocker...?
0
 
BustaroomsCommented:
do you have this posted somewhere?  could you provide a url
0
 
devicCommented:


@jaysolomon
ok this was just a joke. :)

@mattaustin,

google toolbar popup blocker is smart. And blocks only unrequested popups.
Use popup with user event, and the popup comes.
0
 
jaysolomonCommented:
I no nuffin about the google popup blocker, maybe busta or devic do.
0
 
BustaroomsCommented:
meaning, if you have a link that opens a popup, Google will let it through for example
<a href="#" onclick="window.open('http://www.google.com','googleWin');return false;">Open Google</a>

but if you try

<body onload="window.open('http://www.google.com','googleWin');">

Google will swat that ish
0
 
mattaustinAuthor Commented:
devic-  

how do i Use popup with user event ?


http://www.mycoolphone.com/popuptest.html
0
 
devicCommented:
if for example user clicks the link or button <input type=button onclick=mypopup()>
0
 
devicCommented:
mattaustin,

here is my example, how to check if exists a window.


============================================
<html>
<head>
    <title>Untitled</title>
<script>
//created by devic
//super puper popup tester
function popUp(url, myname, w, h, scroll) {
     var winl = (screen.width - w) / 2;
var wint = ((screen.height - h) / 2)-20;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=0, status=0, resizable=0,menubar=0'
eval(myname+" = window.open(url, myname, winprops)");
if (parseInt(navigator.appVersion) >= 4) { eval(myname+".window.focus()"); }
}

function checkWindow(namez)
{
      try{
            if(eval("window."+namez+".document"))
            {
                  alert("Window \""+namez+"\" open");
            }
            else
            {
                  alert("Window \""+namez+"\" not found");
            }
      }
      catch(e)
      {
            alert("Window \""+namez+"\" not found");
      }
}
</script>
   
</head>

<body>

<a href="somePage.htm" onClick="popUp('','test1','295','300','no');return false;">Test1</a>
<br />
<a href="somePage.htm" onClick="popUp('','test2','295','300','no');return false;">Test2</a>
<p />
<input type="submit" value="test window test1" onClick="checkWindow('test1');" />
<input type="submit" value="test window test2" onClick="checkWindow('test2');" />
</form>
</body>
</html>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.