?
Solved

How to identify whether the pop up windows are blocked in the browser through javascript?

Posted on 2014-01-12
2
Medium Priority
?
659 Views
Last Modified: 2014-01-13
Hi,

How to identify whether the pop up windows are blocked in the browser through javascript?
Is there any javascript available to identify?

I just need to provide alert to user to enable pop up in case if it is blocked
0
Comment
Question by:Rocking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 1000 total points
ID: 39775037
You need to open a popup and check for its existence

var mypopup= window.open('/mypopup.php', 'mypopupname');
if (mypopup== null || typeof(mypopup)=='undefined') { 	
	alert('Please disable your pop-up blocker'); 
} 

Open in new window

Of course you could do a quick open and close (if it exists) e.g.
var mypopup= window.open('/mypopup.php', 'mypopupname');
if (mypopup== null || typeof(mypopup)=='undefined') { 	
	alert('Please disable your pop-up blocker'); 
}
else{
	mypopup.close()
}

Open in new window

0
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 1000 total points
ID: 39775042
So a simple way is to change the part of the code that would execute the pop up, put it into a variable and check to see if it is null or undefined. Note that this method doesn't work if you want to try to detect if they have pop up blocking on prior to a click that would open the pop up. This is because every browser is different and pop up blocking is a browser setting,  not an html setting.

<script type="text/javascript">
function buttonClicked() {
  var targetWin= window.open("popup.php");

  if(targetWin==null || typeof(targetWin)=='undefined')
  { 
    alert('Pop ups are required for parts of this application to work. Please Turn off your Pop Up blocker');
  }
}
</script>

<input type="button" onclick="buttonClicked();" value="Click For Pop Up" />

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question