0

I have a plain javascript function for opening a pop up window. This works fine in chrome and firefox. But in Safari, since pop up blocker is enabled by default, its neither opening the page nor there is no error notice.(is it possible to get an error notice?) Can this be done using any jquery method without using window.open(). Please someone help me in this?

var gomWin = window.open(popupURL, 'params');
Tushar
  • 85,780
  • 21
  • 159
  • 179
user1049057
  • 459
  • 4
  • 15
  • 36
  • Check out this post http://stackoverflow.com/questions/2914/how-can-i-detect-if-a-browser-is-blocking-a-popup, it gives examples on how to detect if popups are blocked in Javascript. – Alex Aug 24 '15 at 09:49
  • @jaco - Thanks for the reply. This solution doesn't seem to work in safari. Its not alerting anything. – user1049057 Aug 24 '15 at 10:14

1 Answers1

1

There is no jQuery method that I know of to do that.

In order to test whether the call to window.open succeeded your should test the returned value:

var gomWin = window.open(popupURL, 'params');
if (gomWin === null)
  alert("Popup blocked!");
POZ
  • 583
  • 4
  • 11
  • Thansk for the reply. if (gomWin === null) did not give any alert. But if (typeof gomWin == 'undefined'){alert("Popup blocked!");} gave the alert. But the problem is it alerts even if the pop up is not blocked. Any idea why it is happening? – user1049057 Aug 24 '15 at 09:55
  • It might be a behavior related to Safari. You may want to test the returned value is several different ways as shown in the post suggested by Jaco. – POZ Aug 24 '15 at 10:03