在浏览器中访问其他选项卡的内容 [英] Accessing the content of other tabs in a browser

查看:48
本文介绍了在浏览器中访问其他选项卡的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Mozilla Firefox,我正在尝试找出一种使用 JavaScript 和 DOM 访问同一窗口中其他选项卡内容的方法(如果存在其他技术,我愿意接受).

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).

例如,我想在 tab1 中运行 JavaScript 代码,它可以找到其他标签的标题.基本上我需要这个,以便我可以在不使用 window.open 方法的情况下识别在当前页面中因 href 而打开的选项卡.我想要的只是一个简单的超链接,它打开一个与当前页面属于同一域的页面(该页面应该在新选项卡中打开).现在我希望能够从当前选项卡访问这个新选项卡.

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.

推荐答案

您可以使用 HTML5 跨窗口消息传递(archive.org 链接...但这有点前沿.

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

即使在这种情况下,您也可能需要劫持 <a>使用 JavaScript 标记 'click' 事件并自己打开窗口,以便您可以访问用于发布消息的新窗口对象.

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.

这篇关于在浏览器中访问其他选项卡的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆