简体   繁体   中英

When click a <a> link in chrome extension, how can popup.html keep open state?

I'm doing a Chrome extension about looking though posts from a forum.

Now,I can get some posts' links and I put these links into in my popup.html like this:

<a href="post's link" target="_blank">post's title</a>

Then when I click the link, a new tab will be opened, but the popup.html page will disappear.

And when I click with pressing , new tab will be opened, but problem still exists.

Now, I want to know if I can open a new tab by clicking a link, and in the meantime I can keep my popup.html page still Show.

I refer to the documentation of chrome extension development, but I still can not solve this problem.

So, can this be realized? And how?

Thanks!

I believe you can't do that with target="_blank" , see FAQ Persist Popups

popups automatically close when the user focuses on some portion of the browser outside of the popup. There is no way to keep the popup open after the user has clicked away.

However (thanks to @Bob den os for the idea), you could use chrome.tabs.create with active: false , in this way, the new tab is created without having focus, you can stay the popup open.

chrome.tabs.create({
    url: "xxx.com",
    active: false
});

Chrome extensions popup windows require focus to stay open.

How to keep Google Chrome Extension popup open?

It is possible to open the popup window into a new tab. Which does not require focus to stay open.

chrome.tabs.create({ url: chrome.extension.getURL('popup.html')});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM