Web Tools Table Maker3schools TranslateImage CompressorFavicon Icon GeneratorCrop & Resize Image
Apu
Apu October 27, 2022 › #browser #HowTo

How to check pop-up blocker using JavaScript

To open a new tab, we use the open() method of the window object. e.g. window.open('https://example.com).

How to Check if popup is blocked using JavaScript. #

But in some cases, the browser blocks it. So, this article will explain how to check whether popups are blocked in browsers (Chrome, Firefox, Edge etc.) using JavaScript.

Example : how to check if popup is blocked. #
<script>
 const url='https://example.com'
 const openUrl = window.open(url);             
 if(!openUrl || openUrl.closed || typeof openUrl.closed=='undefined'){ 
  alert('Pop ups are blocked')
 }else{
  alert('Pop ups are not blocked')
 }
</script>
Try it Yourself »
save
listen
AI Answer
Write Your Answer
loading
back
View All