Firefox:动态 XUL 构建?
嘿!
这是我到目前为止已经做过的,效果很好:
当用户位于其中之一时,下载浏览器启动的域的 XML 文件 网站会发出警报,欢迎他访问该特定网站。
是的,没什么了不起,但这是一个有趣的学习项目:)
这是我的第一个插件,仍然需要学习。
现在我想做的是,向用户显示侧面带有复选框的域列表...所有域都将被选中,但他可以取消选中任何域,并且我不会显示该域的警报。
我该如何制作这个带有复选框的动态页面?完全困惑了。
请帮忙!
谢谢!
Hey!
This is what I have already done so far which works great:
Download an XML file of domains which the browser starts up, when the user is on one of these
sites serve an alert welcoming him to that particular site.
Yes, its nothing great but it's a fun learning project :)
and this is my first addon, still very much learning.
Now what I want to do is, show the user the list of domains with a checkbox at the side... all the domains will be checked but he can uncheck any domain and I wont show the alert for that domain.
How do I go about making this dynamic page with checkboxes? Totally confused.
PLEASE HELP!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有提到您的用户界面在哪里显示。如果您正在制作基于 HTML 网页的 UI,那么您可以使用任何网页所使用的相同技术来构建 UI - JS 和 DOM。由于您的网页是从加载项加载的,因此您可以选择使用更高的代码权限,而不必像传统网页那样被沙箱化。
如果您将 UI 托管在 Firefox chrome 本身中,则可能使用 XUL,而不是 HTML。然而,当使用 XUL 构建 UI 时,您仍然使用 JS 和 DOM。查看 MDC 上的 XUL 参考和教程,了解有关可用 UI 元素类型的信息:
https://developer。 mozilla.org/en/XUL_Reference
https://developer.mozilla.org/en/XUL_Tutorial
因为你的 UI 代码和域 -检查位于两个不同区域的代码,您将需要一种共享状态的方法。这样,域检查代码将知道是否显示给定域的警报。将 UI 保留在主 Firefox XUL UI 中使这变得容易 - 域检查代码和 UI 代码位于同一范围内。
如果您的 UI 位于 Chrome 网页中,您应该能够访问主浏览器窗口(域检查代码所在的位置)并更新数据结构。以下是从特权网页访问外部 Chrome 窗口的代码片段:
https://developer.mozilla.org/en/Working_with_windows_in_chrome_code#Accessing_the_elements_of_the_top-level_document_from_a_child_window
希望这可以帮助您入门。
You didn't mention where your UI is being displayed. If you are making a HTML webpage based UI, then you can use the same techniques used by any webpage to build a UI - JS and DOM. Because your webpage is being loaded from an add-on, you have the option to use higher code privileges and not be sandboxed like a traditional webpage.
If you are hosting your UI in the Firefox chrome itself, you are likely using XUL, not HTML. However, you still use JS and DOM when build a UI using XUL. Check out the XUL reference and tutorial on MDC for information on the types of UI elements available:
https://developer.mozilla.org/en/XUL_Reference
https://developer.mozilla.org/en/XUL_Tutorial
Because your UI code and the domain-checking code live in two different areas, you will need a way to share the state. That way the domain-checking code will know whether or not to show the alert for a given domain. Keeping the UI in the main Firefox XUL UI makes this easy - the domain-checking code and the UI code are in the same scope.
If your UI is in a chrome webpage, you should be able to access the main browser window (where your domain-checking code lives) and update a data structure. Here is a code snippet for accessing the outer chrome window from a privileged webpage:
https://developer.mozilla.org/en/Working_with_windows_in_chrome_code#Accessing_the_elements_of_the_top-level_document_from_a_child_window
Hope this helps get you started.