简体   繁体   中英

How to select a browser tab from another tab?

I want to select a browser tab from another tab. For example one of my web app is opened in a browser and I opened a link in another tab. Now I want to select my first tab using a shortcut key like "CTRL+M" or something like that.

How can I do this?

You are not able to select anything outside your HTML-structure programmatically. The only option you have, is to close the current tab so it may jump back to the last tab:

window.close();

Even this approach is based on some assumptions and unreliable. Don't go that way ;)

As far as I know this only works if one of the tabs is a popup of another tab. Then you can use

window.opener.focus();

To focus the tab that opened the pop up and

popupName.focus(); 

To focuse the pop up

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