Foreground a certain window and switch to a certain tab within it

I want to make a desktop shortcut that switches to certain window/tab in chrome.

But ignoring that- lets just say I want to do that from a link on a page. Is that even possible?

So that if I have a bunch of windows open I can switch to one of them without having to find where it is among my (too) many open tabs and windows.

I was thinking it’s probably not because it could be used maliciously…

Also let’s assume that I instantiated the window, so that I have a handle on it.

(I’d like to do this in jquery but I’ll take anything).

Any ideas?

sq

Hi @Bog, yes in that very case you can focus it programmatically:

const myWindow = window.open('http://example.com/')
// Then later...
myWindow.focus()

Other than that you might use the chrome tabs API to switch tabs, but that’s only available to chrome extensions (with appropriate permissions), not web pages. Indeed, it sounds like an extension is better suited for the functionality you’re trying to implement anyway…

Thanks @m3g4p0p! Here’s what I ended up doing:

<script>
var mwindow=false;
function airtable() {
	if (!mwindow) {
		mwindow = window.open('https://google.com', "_blank", "toolbar=yes,top=500,left=500,width=1000,height=700");
	}
	mwindow.focus();
}
</script>
<a style="font-size:12pt;font-style:bold;" href="javascript:void(0)"  onclick="airtable();">open or focus airtable</a>

When you open that html file in your browser and click the link, it will open up a google window (I’m just using google as an example obviously; I’m using another site. ) From then on if you click the link it will just foreground the child window instead of opening a new one.

So what I do is minimize the window as much as possible and move it to the upper right corner, mostly off-screen; and any time I want it foreground it I can just click the link.

However! Chrome has a minimum size you can minimize to with the window edge grips, manually. But you can get around that when you programatically open a window with window.open(). You can open a window that’s, say, 50x50 (or probably even less); something about the size of a desktop icon, which accomplishes my original goal. I didn’t put that in the script above but I tested that I can do it, maybe I’ll add it later.

Oh EDIT:

Apparently chrome stupidly restricts what you can do in the attributes of a popup window. https://bugs.chromium.org/p/chromium/issues/detail?id=82522

Well, so what I do is just open the window in a new tab and drag the tab out to a new window and it works ok from there with all the buttons and bar you can do in a normal window. It’s still an idiot bug on google’s part; they’re going off the standard. So just remove the extra params and change the above to:

window.open(‘https://google.com’, “_blank”)

Thanks,

bog