我在一个窗口中自定义了一个确认框,该框在3秒钟后显示。 3秒钟后,当显示确认框并且用户在另一个窗口中时,我希望焦点对准显示确认框的窗口。
尝试了以下方法,但没有任何效果 1. window.focus() 2. alert()可以按预期工作,但是我需要在警报消息中显示一个倒数计时器,这是通过本机警报功能无法实现的(据我搜索)。 3.尝试设置window.name并通过window.open('','windowName')
进行调用引用了其他链接,但没有任何帮助。 How to focus window/tab like alert()? How to get focus to a Chrome tab which created desktop notification? 有什么方法可以将焦点强制到窗口吗?
功能就是这样
$(document).ready(function () {
window.name = "Dashboard";
var timerInterval = setInterval(function() {
showConfirmationPopup(); // a popup which displays a countdown timer
window.focus(); // didn't work
window.open('','Dashboard'); //didn't work
alert('Your remaining time is ' +countdownTimer); // Can use this to force focus to window but doesn't work to display a countdown timer also I need the alert box to be a customized one.
}, 3000);
});