1

How can I avoid getting pop-up blocked? Whenever I click the button, the notification pops up and says that it will be redirected like I said. But chrome says it is unable to open the new tab because it has pop-up blocked.

$(function () {
    $('#clickBtn').on('click', function () {
         new Noty({
              type: 'success',
              layout: 'topRight',
              timeout: timeout,
              text: '<p style="text-align: center">Redirecting in 5 
                     seconds</p>'
         }).show();

              var url = 'https://google.com',
                    delay = 5000; // Milliseconds: 1sec x 1000

              setTimeout(function () {
                    window.open(url, '_blank');
              }, delay);
         });
Nitish Kumar Diwakar
  • 625
  • 4
  • 13
  • 25
Sneaky
  • 11
  • 1
  • 4
  • Redirecting inside a callback is a common technique used by pop-up ads. Hence it is blocked. – Rajesh Jul 19 '17 at 05:28
  • [Another one](https://stackoverflow.com/questions/9514698/bypass-popup-blocker-on-window-open-when-jquery-event-preventdefault-is-set). You can find more [here](https://www.google.co.in/search?q=Window.Open+being+pop-up+blocked%2C+how+to+fix%3F&oq=Window.Open+being+pop-up+blocked%2C+how+to+fix%3F&aqs=chrome..69i57j69i60.3130j0j7&sourceid=chrome&ie=UTF-8) – Rajesh Jul 19 '17 at 05:31

1 Answers1

1

You cant avoid popup blocker, But You can check is browser blocked popups or not ..

var windowName = 'userConsole'; 
var popUp = window.open('htttp://www.google.com', windowName, 'width=1000, height=700, left=24, top=24, scrollbars, resizable');
if (popUp == null || typeof(popUp)=='undefined') {  
    alert('Please disable your pop-up blocker and try again.'); 
} 
else {  
    popUp.focus();
}

Check Here

suraj mahajan
  • 814
  • 1
  • 10
  • 20