Thursday, July 12, 2007

Firefox in Firefox!
Here's something of a "Do you know?" variety.
One of the great things about Firefox is that its interface is highly modular and creating an extension or a plugin is as simple as editing xml files and writing Javascript code (things most web designers do on a daily basis). Firefox renders its interface with the appropriate theme by evaluating an xml file. So effectively, Firefox renders itself by evaluating its own interface file and placing widgets as defined in it in a blank application window. Well, I just came to know that it's possible to load Firefox within itself by asking it to evaluate its own interface using a chrome:// uri. Don't be surprised - just try typing chrome://browser/content/browser.xul in the address bar and see the results. The new interface is a fully functional Firefox!
Now, for the more curious among you - the reason why this works is because the chrome:// uri is interpreted by the firefox engine as a reference to its chrome directory and the subsequent paths provided are used to navigate the inner tree structure. The xul file is interpreted as an interface and rendered as such, complete with all event handlers - giving you a complete browser within a browser. To see the innards of Firefox, open up the browser.jar in the chrome directory of your Firefox installation using any standard unzipping utility and look at content/browser/browser.js and content/browser/browser.xul to have a feel of how flexible my favourite browser actually is!