Home > programming > XULRunner rocks!

XULRunner rocks!

March 15, 2011

For one of my projects, I needed an application to display a web page in full screen mode. At first, I used Firefox with the AutoHide extension, but this solution was more of a hack and not easy to deploy to multiple machines — I worked with a pre-configured user profile that was copied every time the application started. Furthermore, after each update, Firefox would check for compatibility of installed plugins and displayed a nasty dialog in the meantime.

So I tried to move away from Firefox and do something on my own, something slim which did just what I wanted, nothing more, and do it good — according to the UNIX philosophy. But writing another C/C++/Python/whatever application from scratch was not an option (implementing an HTML renderer would be a pain, and I didn’t fancy reading extensive manuals about WebKit, Gecko or any other rendering engine).

After a while of thinking, which included thought fragments of Songbird and Conkeror, I decided to give XULrunner a shot (for those who do not know, XUL is the XML-based user interface language used by the Mozilla applications and the Firefox and Thunderbird extensions, and XULRunner is an interpreter and run-time environment for XUL documents).

So after a while of hacking (there is a good tutorial on the Mozilla Developer Network), I ended up with a few lines of code:

File ./chrome/content/main.xul:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="main.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  id="viewer" windowtype="viewer" title="Infopoint HTML View" 

  <hbox flex="1">
  <iframe id="contentview" flex="1"
    src="chrome://infopointhtmlviewer/content/default.html" />
    // load URI given on command line
    var content = document.getElementById("contentview");
    var cmdLine = window.arguments[0].QueryInterface(
    var uri = content.getAttribute("src");
    alert("Default URL: " + uri);
    if(cmdLine.length > 0) {
      uri = cmdLine.getArgument(0);

    if(content != null) {
      content.setAttribute("src", uri);

    // resize to full screen
    window.resizeTo(screen.width, screen.height);

The above code is in the public domain.

And that was basically all of it. I was surprised that there was nothing more to it.

You can get the source code of the full application on Github.

Flattr this

%d bloggers like this: