0

I am using JavaScript code to check if users browser has popup blocker enabled or disabled which is working fine in all the browser except in IE. IE doesn't seem to be blocking the popups opened from same domain. Any suggestions?

var popUpStr;
var popUp = window.open("Name of popup which has same domain as the main windown", "", 'width=150, height=150, left=24, top=24, scrollbars, resizable');
if (popUp === null || typeof (popUp) == 'undefined' || typeof (popUp.location.hash) != "string" || (popUp === null && popUp.outerWidth === 0) || (popUp !== null && popUp.outerHeight === 0)) {
    popUpStr = 'Popup Blocker is enabled';
} else {
    popUp.close();
    popUpStr = 'Popup Blocker is not enabled';
}
j08691
  • 204,283
  • 31
  • 260
  • 272
  • var popUpStr; var popUp = window.open("Name of popup which has same domain as the main windown", "", 'width=150, height=150, left=24, top=24, scrollbars, resizable'); if (popUp === null || typeof(popUp)=='undefined' || typeof(popUp.location.hash)!= "string" || (popUp === null && popUp.outerWidth === 0) || (popUp !== null && popUp.outerHeight === 0) ) { popUpStr = 'Popup Blocker is enabled'; } else { popUp.close(); popUpStr = 'Popup Blocker is not enabled'; } – user3654109 Jun 13 '14 at 15:05
  • Generally speaking, pop-ups from the same domain are the kind of pop-up that you *don't* want to block anyway... – Niet the Dark Absol Jun 13 '14 at 15:08
  • Please post code into your question by editing it, not in a comment. I've updated your question for you. – j08691 Jun 13 '14 at 15:09

1 Answers1

0

Your Code works fine for me in a JSFiddle in IE11. Maybe you should narrow the browser version.

Further, check out these threads with the same subject, you also will find more elegant jQuery solutions:

Community
  • 1
  • 1
peter_the_oak
  • 3,529
  • 3
  • 23
  • 37
  • I am debugging JavaScript and i am seeing the window.open is not null when i turned on the popup blocker. It is always going in to the else block. – user3654109 Jun 13 '14 at 15:45
  • In your boolean expression, you declare five reasons to go to the if block. The part `popUp !== null && popUp.outerHeight === 0`is the only that forces the if block even popUp is not null. What is the value of popUp.outerHeight in IE, for this term? Maybe you find another criteria to catch? – peter_the_oak Jun 14 '14 at 05:22
  • popUp.outerHeight and popUp.outerWidth are erroring out. they are meant for chrome browser – user3654109 Jun 16 '14 at 13:28