如何避免被阻止弹出窗口?每当我点击按钮,通知弹出,并告诉它将被重定向,如我所说。但chrome表示,它无法打开新标签,因为它阻止了弹出窗口。
$(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);
});发布于 2017-07-19 13:32:35
你无法避免弹出窗口阻止程序,但你可以检查浏览器是否阻止了弹出窗口。
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();
}https://stackoverflow.com/questions/45181635
复制相似问题