If you are talking about dynamically opening a new tab, by clicking on a link and having that click call window.open();
, then .open()
returns a reference to the child window, which you can then communicate with in the parent script: var childWindow = window.open(url);
Otherwise, cookies?
A session-parameter in the query string, which you could change if a new tab was opened.
Another suggestion, if you're using html5-audio exclusively, would be something like using localStorage
.
Most browsers supporting HTML5 window.Audio;
also support window.localStorage;
.
You'd have to expressly check to see that localStorage is indeed supported and enabled, but that's just good citizenship.
Then you should be able to set a randomized ID for the tab, save that ID in session-storage, set an "is_playing" or whatever field in localStorage to the ID you gave the tab in sessionStorage...
...and then on each new tab, check to see if "is_playing" is empty in localStorage, OR if the ID is equal to the one set in sessionStorage.
The difference between localStorage and sessionStorage is that sessionStorage is emptied after you close the browser, and it also should not be shareable between tabs.