2017-06-02 122 views
0

我做了创建或打开新的选项卡/窗口/页面的Chromium浏览器插件然后放置消息。但是,当警报弹出正在执行时,为什么焦点回到父页面?如何防止窗口(选项卡)打开一个新的,并提醒弹出窗口后执行

if(document.getElementById('watch-headline-title')) { 
    var Button = document.createElement('button'); 
    Button.className = 'yt-uix-button 
    Button.onclick = function(){ 
    open('https://ycapi.org/iframe/?'+document.URL.match(/v=[a-zA-Z0-9-_]{11}/)+'&f=mp3'); 
    setTimeout(function() {alert("For Demo only on asking StackOverflow Purpose. Wait for 2s ");}, 2100); 
} 
    document.getElementById('watch-headline-title').appendChild(Button); 

}

请人给我一个benefitfull指导...提前很多感谢。

回答

0

试试这个,请: (添加.focus())

(...) 
open('https://ycapi.org/iframe/?'+document.URL.match(/v=[a-zA-Z0-9-_]{11}/)+'&f=mp3').focus(); 
(...) 

告诉我,如果这是你所需要的。

+0

无法正常工作..请哟请向我介绍任何密切相关的主题指南/讨论。 – Budi

+0

也许[此链接](https://stackoverflow.com/questions/2965754/set-the-focus-of-a-popup-window-everytime)可以帮助你,关键的想法:打开一个新标签不会给自动对焦在它上面,所以搜索“如何专注..” –

相关问题