在浏览器中访问其他选项卡的内容

编程入门 行业动态 更新时间:2024-10-26 14:38:04
本文介绍了在浏览器中访问其他选项卡的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 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 链接...但这有点前沿.

You could use HTML5 cross-window messaging (archive 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屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 11:04:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1408792.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项卡   器中   内容

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!