开发者

Firefox: Dynamic XUL building?

开发者 https://www.devze.com 2023-03-06 10:28 出处:网络
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

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开发者_StackOverflow社区 alert for that domain.

How do I go about making this dynamic page with checkboxes? Totally confused.

PLEASE HELP!

Thanks!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消