Mozilla - 如何加载带有先前通过 gBrowser.contentDocument 获取的文档的 TAB?
我正在开发一个简单的 Mozilla Firefox 扩展(FF 5.0 及更高版本),并且我需要一种可以从选项卡获取内容文档的方式,例如:
<JavaScript function called from XUL document>
var content_1 = gBrowser.contentDocument;
目标是将该内容再次放入另一个选项卡中,例如示例:
Application.activeWindow.activeTab.contentDocument = content_1;
但这不起作用,因为 content.document 或 contentDocument 是只读的。
我的意思是,我不想获取 URL 并重新加载页面,而是想获取选项卡的内容本身,然后将其分配给另一个选项卡。
我还想找到一种方法来获取选项卡的内容,包括用户在 HTML 文本框中或文档中的任何位置填写的文本,例如,发送之前的论坛帖子文本。我不确定这最后一件事是否可能,而无需读取内存或使事情变得过于复杂......
I'm developing an easy Mozilla Firefox extension (FF 5.0 and above), and I need a manner in which I can get the content document from a tab, for example:
<JavaScript function called from XUL document>
var content_1 = gBrowser.contentDocument;
and the goal is to put that content again in another tab, for example:
Application.activeWindow.activeTab.contentDocument = content_1;
but that's not working becasue content.document or contentDocument are read-only.
I mean, instead of getting the URL and reloading the page, I would like to the the tab's content itself and then assign it to another tab.
I'd also like to find a way to get the content of a tab including text filled in by a user in HTML textboxes or wherever in the document, for example, a forum post text before sending it. I'm not sure this last thing is possible whithout having to read the memory or complicating too much the thing...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法更改
contentDocument
,但可以更改文档内容。特别是,您可以替换文档的根节点。应该这样做:当我尝试复制文档的内容时,包括文本框输入等动态信息。
You cannot change
contentDocument
but you can change document contents. In particular, you can replace the document's root node. This should do:When I tried this copied document's contents including dynamic information like textbox input.