在XUL中,我如何知道浏览器标签已经完成加载?

编程入门 行业动态 更新时间:2024-10-27 04:35:58
本文介绍了在XUL中,我如何知道浏览器标签已经完成加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发基于本教程这是一个FF 2.0扩展(本教程的第二部分在此网址)

I'm developing a firefox extension based on this tutorial which is a FF 2.0 extension (second part of the tutorial is at this url)

主要的是重要的是它使用

The main thing that is important is that it uses

<iframe id="contentview" src="www.ibm/developerworks/web" flex="2"/>

在后端代码中,当点击GO按钮时,会发生这种情况:

In the backend code, when clicking the GO button, this happens:

contentview.contentDocument.location.href = urlbox.value; //Use Firefox XPath to get the raw text of the document var doctext = contentview.contentDocument.evaluate( "string(.)", document, null, XPathResult.STRING_TYPE, null).stringValue;

我收到xpath的错误,但这不是我的问题。我使用FF 3.0的问题是contentDocument值是指加载的旧站点,而不是由href-change加载的站点。

I get an error with the xpath, but that's not my question. The issue I have with FF 3.0 is that the contentDocument value refers to the old site loaded, not to the one loaded by the href-change.

所以我的问题是:我如何创建一个类似的窗口,但是当加载的文档完成时会被通知某人,所以我可以访问其DOM?

So my question is: how can I create a similar window, but be notified someone when the loaded document is complete, so I can access its DOM?

推荐答案

更新: 首先,您需要处理窗口的加载事件,然后向iframe元素添加事件侦听器

Updated: first you need to handle the load event of the window then you add an event listener to the iframe element

window.addEventListener("load",Listen,false); function Listen() { var frame = document.getElementById("contentview"); frame.addEventListener("DOMContentLoaded", DomLoadedEventHandler, true); } function DomLoadedEventHandler() { var frame = document.getElementById("contentview"); alert(frame.contentDocument.location.href); }

将DomLoadedEventHandler替换为您的事件处理程序名称。

replace "DomLoadedEventHandler" with your event handler name.

我建议您查看Mozilla的官方网站,了解有关Firefox扩展的所有信息

I recommend that you take a look at the official site of Mozilla to learn everything about Firefox extensions

developer.mozilla

更多推荐

在XUL中,我如何知道浏览器标签已经完成加载?

本文发布于:2023-08-02 13:28:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1278190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   浏览器   标签   XUL

发布评论

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

>www.elefans.com

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