I am something of a XUL newbie, so please bear with me... I have been
unable to determine via Google whether the following is feasible.
Is it possible to have a toolbar that generates on-the-fly using
XMLHttpRequest?
To be more specific, what I would like to achieve is a menupopup where
the menuitem elements are generated from data from an XMLHttpRequest,
when the toolbar is loaded (ie when Firefox is started). It would be
even nicer if this could be refreshed "live", but I am very doubtful
that this would be possible.
If this is possible, can anyone point me to an example? If it is not
possible, any equivalents or work-arounds?
Cheers
M
--
Matthew Smith
IT Consultancy & Web Application Development
Business: http://www.kbc.net.au/
Personal: http://www.smiffysplace.com/
LinkedIn: http://www.linkedin.com/in/smiffy
> To be more specific, what I would like to achieve is a menupopup where
> the menuitem elements are generated from data from an XMLHttpRequest,
> when the toolbar is loaded (ie when Firefox is started).
Live bookmarks work like this, although I don't know if they use
XMLHttpRequest under the hood. You could try looking at the part of
firefox source that deals with live bookmarks.
Off the top of my head, I see a few ways to implement this
1) By building your menupopup from an RDF datasource, which could be
generated on the server. I dislike RDF, so I personally probably
wouldn't use it.
2) By getting data (e.g. JSON string) from the server, parsing it on
client, and building the menupopup using DOM methods (such as
document.createElementNS).
3) By getting data as XML from the server.
- server can just send the XUL code to use for popup
- alternatively it can send generic XML describing the attributes of
the items in the menu and you generate the XUL on client by applying
an XSLT transform.
Nickolay
> 3) By getting data as XML from the server.
> - server can just send the XUL code to use for popup
> - alternatively it can send generic XML describing the attributes of
> the items in the menu and you generate the XUL on client by applying
> an XSLT transform.
Does this work? I know some parts of our DOM dislike being added to
documents that don't own them.
--
Warning: May contain traces of nuts.
Nickolay
XSLTProcessor.transformToFragment takes as a parameter a document
object. The result is a document fragment owned by that document. One
then can use DOM methods to merge the fragment into the document.
Igor Tandetnik