Skip to content
Advertisement

Accessing the content of other tabs in a browser

I am using Mozilla Firefox and I am trying to figure out a way to access the content of other tabs in the same window using JavaScript and the DOM (I am open to other techniques if exist).

E.g., I want to run JavaScript code in tab1 which can find the title of some other tab. Basically I need this so that I can identify a tab which has opened due an href in my current page without using window.open method. All I want is a simple hyperlink which opens a page belonging to the same domain as the current page (the page should be opened in a new tab). Now I want to be able to access this new tab from the current tab.

Advertisement

Answer

You could use HTML5 cross-window messaging (archive.org link…but that’s kind of cutting edge.

Even in that case, you’d probably need to hijack the <a> tag ‘click’ event with JavaScript and open the window yourself so that you’d have access to the new window object for posting messages.

Advertisement