2017-07-19 77 views
0

如何避免彈出窗口被阻止?每當我點擊這個按鈕時,通知就會彈出來,並且表示它會像我說的那樣重定向。但是鉻表示它無法打開新標籤,因爲它彈出窗口被阻止。Window.Open被彈出窗口阻止,如何修復?

$(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); 
     }); 
+0

重定向回調裏面是彈出常用的技術廣告。因此它被阻止。 – Rajesh

+0

[Another one](https://stackoverflow.com/questions/9514698/bypass-popup-blocker-on-window-open-when-jquery-event-preventdefault-is-set)。你可以找到更多[這裏](https://www.google.co.in/search?q=Window.Open+being+pop-up+blocked%2C+how+to+fix%3F&oq=Window.Open+正在+彈出+阻斷%2C +如何+修復%3F&AQS = chrome..69i57j69i60.3130j0j7&的SourceID =鉻&即= UTF-8) – Rajesh

回答

0

你不能避免彈出窗口攔截器, 但你可以檢查是瀏覽器彈出窗口阻止或不..

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

相關問題