Take the 2-minute tour ×

I'm working with the facebook SDK and it works through popups due to security issues now.

So I've got a button that deals with facebook [FacebookButton] which is hidden, and a button to test for popup blocker [PopupTester].

My code is like this,

when [PopupTester] is clicked, if a popup works: close it, hide this button, and show [FacebookButton].


when [PopupTester] is clicked, if popup fails, show dialogue to urge to change popup settings, keep [FacebookButton] hidden, change this button value to [Try Again].

function testPopupBlocker() {
  var windowName = 'userConsole'; 
  var popUp = window.open('http://www.whirlocal.com', windowName, 'width=200, height=200, left=24, top=24, scrollbars, resizable');
  if (popUp == null || typeof(popUp)=='undefined') {
    var weGood = "nope";
    alert('Please disable your pop-up blocker and click the link to test again.'); 
  else {
    var weGood = "yup";


This works great, except for the fact that this button always creates a popup, but the Facebook one is still being blocked!

Is there another method besides "window.open" to create a popup? One that is more likely to be blocked?


Here's my button codes

<input type="button" class="genButton testPopupButton" name="Test Popup Blocker" title="Test Popup Blocker" value="Test Popup Blocker" onclick="testPopupBlocker()" style="cursor:pointer;" />

<input type="button" class="genButton needsPopups facebookButton" name="AdvocateOnFacebook" title="Recommend <?php echo genesis_get_option('organization','child-settings');?> on Facebook" value="Recommend us on Facebook!" onclick="advocateToFriends()" style="cursor:pointer; display:none;" />
share|improve this question
add comment

1 Answer

You need to legitimize the popup. It needs to be initiated by the user, and not arbitrary popup code, or else a popup blocker will stop it. Once you have a handle on the popup, then you may modify it however you like.

Try this html code out:

<a href="#" onclick="javascript:window.open('http://myurl.com/blank_page.html','userConsole','width=800,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=auto,resizeable=yes');">
    <div class="some_div_class"><b>Click Me</b></div>

Then run your testPopupBlocker() function and see if it works a little better.

share|improve this answer
Sorry, I should have included the fact that my button activates that function. It's been edited above. –  ZipZopZoobityBop Jun 21 '12 at 20:15
That's fine, you can call the function after the window.open is initiated from the dom element that was clicked. The main point is that window.open has to be called from clicked object first, thus making it a legit popup. –  MMeah Jun 21 '12 at 20:17
"userConsole" is the window handle that ties it all together. Again, legitimize the popup first, then modify it with standard JavaScript after the fact. –  MMeah Jun 21 '12 at 20:21
So it's still not working. look here blackchapman.whirlocal.com/thank-you The facebook one gets blocked. I 'need' the other one to get blocked to notify users that their settings need to be changed, and it's still not getting blocked :/ –  ZipZopZoobityBop Jun 21 '12 at 20:32
If you have one popup working, then why not have that load the FB code for you? Isolate one issue at a time. Get popup to work, then FB to load in that window. –  MMeah Jun 21 '12 at 21:55
add comment

Your Answer


