Saturday, July 14, 2007

A date with XUL

While working on a firefox extension for a feature on paahijen, I had a loong date with XUL. XUL (pronounced as zool, is an XML based User Interface Language). More stuff about xul can be found at XUL - MDC or XUL planet

Basically, I needed a form where I could copy something to clipboard from a document loaded from a HTTP URL. The problem was, I couldn't use the simple Javascript based methods, as access to clipboard is restricted inside mozilla. So I had to have a XUL window with a XUL button and contents loaded from the URL.

One option is to do all the UI in XUL and use XHR for talking HTTP. So I started with XUL UI. If you thought CSS is a bitch, try XUL and you'd almost fall in love with CSS. In short, for someone short on patience, looking for a quick solution, laying out a XUL UI is not an option. Looking for alternatives, I found an interesting alternative in the tutorial on xulplanet, which uses iframes instead. In my opinion, this is a better approach, unless there is a specific need for Client only UI. First, it is simple, and second you don't need to learn a lot of XULgiri.

So the final solution was a XUL window having a XUL button (on which oncommand was implemented to do clipboard copy) and the HTML document rendered in iframe.

One last issue is - to get contents inside an iframe. The solution is mentioned here.

Guess, thats it, rest of the stuff is quie straight forward.

No comments: