How to make links that open new windows work in XULRunner-based browser?
Using XULRunner, I’m working on a custom, kiosk-style browser for my
company. When clicking on a link that opens in a new window
(target=”_blank”), nothing happens. The JS console shows “No chrome
package registered for chrome://navigator/content/navigator.xul .” From
an LXR search for “navigator.xul”, I guessed a pref named
“browser.chromeURL” might have something to do with this (though not
referenced by a toolkit/ file), so I added it, pointing to my XUL file.
Now this works, but it will always open a new window. I actually want
to prevent links from opening in new windows, so I implemented
nsIBrowserDOMWindow and set the window’s browserDOMWindow property on
startup. However, my code never gets called (aside from
QueryInterface). As far as I see, I have done everything similar to how
Firefox does it - what am I missing?
I’d appreciate any pointers.
Best regards,
Jens
// in startup function:
window.browserDOMWindow = new MyProductBrowserAccess();// further below, same JS file:
function MyProductBrowserAccess()
{
}
MyProductBrowserAccess.prototype =
{
QueryInterface: function ( iid )
{
dump( "QIn" );
if ( iid.equals(Components.interfaces.nsIBrowserDOMWindow ) ||
iid.equals(Components.interfaces.nsISupports ) )
{
return this;
}
throw Components.results.NS_ERROR_NO_INTERFACE;
},
openURI : function ( url, openerWin, where, context )
{
dump( "openURIn" );
return openDialog( MY_PRODUCT_CHROME_URI, "_blank",
"all,dialog=no", url );
},
isTabContentWindow : function ( win )
{
dump("isTabContentWindown");
return false;
}
}
