Search code examples
urlwindow.openxulrunner

Define XULRUNNER default window url


I need to do a simple task but it looks like very heavy for me, i need to create XULRUNNER system which opens WWW.test.com in default window without address bar or any menu and nothing more, here are my codes but it doesn't seem to be working, can anybody help?

main.js

function url() {
  windowObjectReference = window.open("http://www.test.com/", "test_WindowName", strWindowFeatures);
}

main.xul

<?xml version="1.0"?>

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

<window id="main" title="My App" width="500" height="500" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/javascript" src="chrome://myapp/content/main.js"/>
</window>

pref.js

pref("toolkit.defaultChromeURI", "chrome://myapp/content/main.xul");
pref("toolkit.defaultChromeFeatures", "chrome,dialog=no,all");
 pref("toolkit.singletonWindowType", "xulmine");

/* debugging prefs, disable these before you deploy your application! */
pref("browser.dom.window.dump.enabled", true);
pref("javascript.options.showInConsole", true);
pref("javascript.options.strict", true);
pref("nglayout.debug.disable_xul_cache", true);
pref("nglayout.debug.disable_xul_fastload", true);


Solution

  • Just use the <browser> element

    <?xml version="1.0"?>
    
    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
    
    <window id="main" title="My App" width="500" height="500" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    
        <script type="application/javascript" src="chrome://myapp/content/main.js"/>
    
        <vbox id="browerbox" flex="1">
            <browser flex="1" id="testbrowser" src="http://www.test.com/ />
        </vbox>
    
    </window>
    

    The browser is very powerful element I would read up on all Attributes, Properties and Methods that you can use with it, https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/browser. What I gave you above will work but depending on what you ultimately need to do, you may need make a few changes.