9

I have not ever used XUL and it seems quite mysterious. What does it take to create a simple XUL application that simply loads a webpage on a Linux environment?. No need for window decorations, history, back or forward buttons. Just the simplest possible XUL app that loads a web page... Using xulrunner with GRE version 10.0.11.

Also, where is the best place to get tutorials to learn about writing XUL application?

Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Chimera
  • 5,884
  • 7
  • 49
  • 81

4 Answers4

3

I found the answer. Here is one one way to do it.

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="Konami Browser" width="800" height="600" 
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <browser type="content" src="http://google.com/" flex="1"/>
</window>

Of course the other files in the directory structure are required as well.

Chimera
  • 5,884
  • 7
  • 49
  • 81
3

Maybe this will do the trick, loading the page from the commandline argument:

Start with:

xulrunner /path/to/application.ini -test "http://www.google.nl"

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<script type="application/x-javascript"> <![CDATA[
    function init_browser()
        {
        var cmdLine = window.arguments[0];
        cmdLine = cmdLine.QueryInterface(Components.interfaces.nsICommandLine);
        document.getElementById('id_browser').src = cmdLine.handleFlagWithParam("test", false));
        }
]]></script>

 <window id="main" title="Konami Browser" width="800" height="600" 
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    onload="init_browser();">
        <browser id='id_browser' type="content" src="http://google.com/" flex="1"/>
</window>

]]></script>
Rembunator
  • 1,305
  • 7
  • 13
  • Also this might be of interest: [mozilla cmdline](https://developer.mozilla.org/en-US/docs/Chrome/Command_Line) – Rembunator Feb 12 '13 at 08:05
  • I just saw that this link is also referred to on the page that CuriousMind mentioned. – Rembunator Feb 12 '13 at 08:14
  • I realise this one is a bit old but could you elaborate a little more? Does this require the usual xul application directory structure? That command line looks a little unlikely (missing space?) and is the code youre XUL file? TIA. – J Evans Mar 25 '15 at 19:56
  • I think you can use the __window.arguments__ property in any working xul application at any given time (not just init). It will give you a [nsICommandLine](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICommandLine) object which provides information about the command line used to invoke your application. You could additionally use __resolveURI__ (see the link in my first comment). The XML file in my answer is the main XUL file. Where do you think the space is missing? – Rembunator Mar 26 '15 at 20:33
  • ```xulrunnerapp``` was what threw me. Thanks for an excellent answer, this has been a great help. – J Evans Mar 29 '15 at 15:24
  • Aah, I see. Well, that's understandable. `xulrunner /path/to/application.ini -test "http://www.google.nl"` would have been better. Apparently, you can also do something with __xulrunner-stub__, but I've never really tried that. Anyway, glad I could help. – Rembunator Mar 30 '15 at 13:01
0

Now that you already provided the correct answer you may want to look at a simple XUL Tutorial to answer possible further questions:

http://www.xul.fr/tutorial/

Arian
  • 3,183
  • 5
  • 30
  • 58
0

I dont have XULRunner and hence cant write XUL code, but I found a post here, which gives hint on how to access command line arguments.

CuriousMind
  • 3,143
  • 3
  • 29
  • 54