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 »