Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Browser element + Opening links in a new window

3 views
Skip to first unread message

James Newell

unread,
Oct 16, 2006, 8:40:32 AM10/16/06
to
I wish to open links in a new window. Using the preference "chromeURL"
(the others made no difference) from the topic "How to make links that
open new windows work in XULRunner-based browser?" I got this working
for links with targets but this doesn't work for opening windows with
javascript. When the window is opened with javascript, the current
window is changed to {Object Window" and the new window is directed to
the old url then replaced by the new one.

What am I doing wrong? I am after similar behaviour to firefox.
Thanks.
James

Boris Zbarsky

unread,
Oct 16, 2006, 9:12:38 AM10/16/06
to
James Newell wrote:
> I got this working
> for links with targets but this doesn't work for opening windows with
> javascript.

Opened with javascript how?

-Boris

James Newell

unread,
Oct 16, 2006, 4:41:02 PM10/16/06
to
ie <a href="javascript:window.open('http://www.google.com/');">Some
Link</a>

on a test page I have both:

1. <a href="javascript:window.open('http://www.google.com', '',
'width=400');">javascript</a>
2. <a href="http://www.google.com" target="_blank">_blank</a>

The second one works as expected, opening a new window with the new
content in this new window. The first however opens the new window with
the attributes and url but the old window's content is replaced with
"[Object Window]"

Thanks.

Boris Zbarsky

unread,
Oct 16, 2006, 5:26:27 PM10/16/06
to
James Newell wrote:
> on a test page I have both:
>
> 1. <a href="javascript:window.open('http://www.google.com', '',
> 'width=400');">javascript</a>
> 2. <a href="http://www.google.com" target="_blank">_blank</a>
>
> The second one works as expected, opening a new window with the new
> content in this new window. The first however opens the new window with
> the attributes and url but the old window's content is replaced with
> "[Object Window]"

That's the correct behavior, and should happen in any browser.

If you want to avoid it, put void() around the window.open call.

-Boris

James Newell

unread,
Oct 16, 2006, 6:38:32 PM10/16/06
to
Thanks that works. How does firefox etc achieve this without requiring
the web page designer to put void() around around the call in the html?

Thanks.

Boris Zbarsky

unread,
Oct 16, 2006, 7:19:33 PM10/16/06
to
James Newell wrote:
> Thanks that works. How does firefox etc achieve this without requiring
> the web page designer to put void() around around the call in the html?

It doesn't. The code you quoted replaces the old window with the text "[Object
Window]" in Firefox.

-Boris

James Newell

unread,
Oct 19, 2006, 12:35:48 AM10/19/06
to
How does my window know how to display or hide features in the feature
argument of the window.open function? Is it window.arguments? Or do I
have to name my toolbar, status bar etc a particular name?
Thanks

Boris Zbarsky

unread,
Oct 19, 2006, 12:49:29 AM10/19/06
to
James Newell wrote:
> How does my window know how to display or hide features in the feature
> argument of the window.open function?

Based on the chrome flags passed to the window creator.

Unless you're overriding the window watcher (which is highly not recommended).
The window watcher is what parses the feature string, etc.

-Boris

James Newell

unread,
Oct 19, 2006, 1:13:40 AM10/19/06
to
But when a new xul window of mine opens due to clicking a javascript
link in the browser element, my toolbars, status bar etc in the new
window is not automatically hidden so I figure that my window must be
told about what features are to be displayed for this to work or do I
need to give my elements special names so that the window features are
automatically displayed or hidden as per the javascript code in the
link that was clicked?

Boris Zbarsky

unread,
Oct 19, 2006, 1:37:22 AM10/19/06
to
James Newell wrote:
> But when a new xul window of mine opens due to clicking a javascript
> link in the browser element, my toolbars, status bar etc in the new
> window is not automatically hidden so I figure that my window must be
> told about what features are to be displayed for this to work or do I
> need to give my elements special names so that the window features are
> automatically displayed or hidden as per the javascript code in the
> link that was clicked?

Oh, I see what you mean. Some of the elements in question need to have
particular classes. See the CSS at
<http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/toolkit/content/xul.css&rev=1.87&mark=36-45#31>.

Scrollbars are handled a little differently, but that should Just Work, I would
think.

-Boris

James Newell

unread,
Oct 19, 2006, 3:01:49 AM10/19/06
to
Excellent.
Thanks

0 new messages