XULrunner: window.open in web pages

Closed Forum
Locked
wetfish
Posts: 1
Joined: May 28th, 2006, 9:40 am

XULrunner: window.open in web pages

Post by wetfish »

Hi,
I'm writing a small site specific browser that for all intents and purposes looks like this:

<window>
<browser id="content" flex="1"/>
</window>


I'm trying to support window.open() statements in the remote pages. But I get:

Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]

I've tried a whole lot of approaches, but the one that gets me the closest is putting the following code in an onload handler:

document.getElementById('content').open = function() { window.openDialog("chrome://window.xul","","dialog=no,all",arguments[0]);
}

where arguments[0] is the url to open, and there is javascript in window.xul to fetch this parameter and open the page in it's browser element.

Now this works fine, until the page is refreshed or the location changes (as you'd expect).

I've tried using progress listeners to put the window.open method back on state change, but no matter what I do, I can't override the browser elements window.open method more than once.

The whole approach I'm taking is very ugly. More than likely I'm exploiting a bug, there must be an easier way. Does anyone know how to handle window.open calls in remote web pages (not chrome urls) in xulrunner?

Any help would be much appreciated. I've been searching for days without success.

Andrew
Guest
Guest

Post by Guest »

I too am having similar problems and would appreciate any help.
coty
Posts: 1
Joined: June 27th, 2006, 11:11 pm
Location: Atlanta, GA
Contact:

Post by coty »

I ran into a similar issue a few months ago. Alas, I never got back to working on it. However, I did get some helpful pointers from bsmedberg on the #xulrunner IRC channel. He was working through something related late last year:

http://wiki.mozilla.org/DocShell:Window_targeting

You might try to catch him. Do post the solution if you get to it.

Cheers,
Coty
arno.
Posts: 50
Joined: August 29th, 2004, 12:12 pm

Post by arno. »

I also add the same problem, and tried different approaches.

But at the end, I managed to find an easy way :
just add that preference in your preferences files :
pref("browser.chromeURL", "chrome://browser/content/browser.xul")

(or whatever the url of your main window is)
Locked