2017-06-02 48 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)可以幫助你,關鍵的想法:打開一個新標籤不會給自動對焦在它上面,所以搜索「如何專注..」 –

相關問題