Reputation: 2103
I know JavaScript has a method
window.open(URL,name,specs,replace)
with it I can open a tab or new window with a name eg.
window.open('www.google.com','name1');
And replace the content in same tab by calling
window.open('www.yahoo.com','name1');
Question:
Can I identify I window with set of tab with name?
Example: open all google related link from my webpage in windowname1 and open all yahoo related links in windowname2
Details:
In my webpage I have four links
www.google.com
www.google.com/psearch
www.yahoo.com
www.yahoo.com/mail
When a user clicks first goolge link -> a new window is opened with name ='alpha' when the user clicks second google link -> It does not open a new window but open a new tab in window 'alpha'
When a user clicks first yahoo link -> a new window is opened with name ='beta' when the user clicks second yahoo link -> It does not open a window link but open a new tab in window 'beta'
Upvotes: 1
Views: 1443
Reputation: 119877
You can map the urls to the names of their windows:
var mapping = {
'www.google.com' : 'alpha',
'www.google.com/psearch' : 'alpha',
'www.yahoo.com' : 'beta',
'www.yahoo.com/mail' : 'beta'
}
That way, you can access the name by url, and use the name to open a window or use an existing window:
var name = mapping[url];
window.open(url,name);
Upvotes: 0
Reputation: 944443
No. Browsers provide JavaScript on websites no means of managing tabs/windows beyond a single name for a viewport.
Upvotes: 1