if i do:
var w=open("chrome://xxxx","mywindow","chrome");
setTimeout(function(w) { w.focus() },0,w);
this works just fine, whether the window is already opened or not, it gets the focus.
but i need to pass my window some arguments. the only way i found is to use the openWindow method of the nsIWindowWatcher
interface.
the popup window is correctly opened the first time, but if the window is already there and behind, the focus() method
simply does not work (without any exception). setting the activeWindow field of the window watcher does work better.
any idea anyone ?
var params = {a:"123", b:"456", c:true, d:false};
window.open("chrome://myext/chrome/mywin.xul", "",
"chrome, dialog, modal, resizable=yes", params).focus();
In mywin.xul, you can access the parameters this way:
window.arguments[0].a; // 123
window.arguments[0].b; // 456
window.arguments[0].c; // true
window.arguments[0].d; // false
if i do:
any idea anyone ?
_______________________________________________
dev-extensions mailing list
dev-ext...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-extensions
Actually, if i do what you describe, window.arguments is undefined from mywin.xul.
>From http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMWindowInternal.html#method_open , i can see that
there is no extra argument for the open() method, contrarily to openDialog()
http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMWindowInternal.html#method_openDialog , or the
openWindow method of nsIWindowWatcher http://www.xulplanet.com/references/xpcomref/ifaces/nsIWindowWatcher.html#method_openWindow
>You can pass parameters to the window as the final argument in the open() function; e.g.,
>
>
You're thinking of openDialog.
--
Warning: May contain traces of nuts.
----- Original Message ----
From: Marie Kesquetta <0LOgcN8f...@spambox.us>
To: dev-ext...@lists.mozilla.org
Sent: Monday, February 5, 2007 11:29:16 AM
Subject: Re: How to give focus to a popup window ?
Thanks for your reply.
Actually, if i do what you describe, window.arguments is undefined from mywin.xul.
>From http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMWindowInternal.html#method_open , i can see that
there is no extra argument for the open() method, contrarily to openDialog()
http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMWindowInternal.html#method_openDialog , or the
openWindow method of nsIWindowWatcher http://www.xulplanet.com/references/xpcomref/ifaces/nsIWindowWatcher.html#method_openWindow
eric...@yahoo.com wrote:
> You can pass parameters to the window as the final argument in the open() function; e.g.,
>
i will live with the following: opening my first popup using window.open as i don't need arguments there, then for other popups
use window watcher's openWindow() using the 'dependent' window option. that makes the child popups to open always in front of
the first one but this is acceptable in my case, even if not perfect.
thanks for your suggestions.
Eric H. Jung wrote:
> ...answering my own question: because it's a popup. You could instead send it custom data using an observer in your XUL and publishing a custom notification in the setTimeout() callback.
> http://www.xulplanet.com/tutorials/mozsdk/observerserv.php
> Let me know if you need an example.
>
> From: "eric...@yahoo.com" <eric...@yahoo.com>
> Well, let me ask a dumb question... why not use openDialog() or openWindow()?
>
> From: Marie Kesquetta <0LOgcN8f...@spambox.us>
> Actually, if i do what you describe, window.arguments is undefined from mywin.xul.
>
>>From http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMWindowInternal.html#method_open , i can see
> that
> there is no extra argument for the open() method, contrarily to openDialog()
> http://www.xulplanet.com/references/xpcomref/ifaces/nsIDOMWindowInternal.html#method_openDialog , or the
> openWindow method of nsIWindowWatcher http://www.xulplanet.com/references/xpcomref/ifaces/nsIWindowWatcher.html#method_openWindow
>
> eric...@yahoo.com wrote:
>> You can pass parameters to the window as the final argument in the open() function; e.g.,
>>
>> var params = {a:"123", b:"456", c:true, d:false};
>>
>> window.open("chrome://myext/chrome/mywin.xul", "",
>> "chrome, dialog, modal, resizable=yes", params).focus();
>>
>> In mywin.xul, you can access the
> parameters this way:
>> window.arguments[0].a; // 123
>> window.arguments[0].b; // 456
>> window.arguments[0].c; // true
>> window.arguments[0].d; // false
>>
----- Original Message ----
From: Marie Kesquetta <0LOgcN8f...@spambox.us>
To: dev-ext...@lists.mozilla.org
thanks for your suggestions.
does anyone have an idea how I can let my extension know, when a mail
has been sent correctly? It should not matter, if this event happened
after a "send now" or a "send later" operation. I just need to know,
when the sending of any message has been finished.
Thank you!
Kind regards,
Coco
So first of all (re-)read
http://developer.mozilla.org/en/docs/Working_with_windows_in_chrome_code
1. If you want to open new window and pass parameters to it use either
openDialog or, if you're an XPCOM component, the window watcher. You
don't need to (and shouldn't) focus the opened window manually using
.focus() in this case.
2. If you want to reactivate an existing window, use win.focus(). You
can save the reference when you open window and use it to focus the
window. Alternatively you can retrieve the reference using the window
mediator.
3. If you want to pass parameters to a window that is already open,
you can do something like this:
a) define function send(arguments) in the popup window
b) when you want to pass arguments to an already opened window, call
win.send(args)
c) you may want to call send(window.arguments) in onload handler in the popup.
Nickolay
Nickolay
On 2/6/07, Nickolay Ponomarev <asqu...@gmail.com> wrote:
> On 2/5/07, Marie Kesquetta <0LOgcN8f...@spambox.us> wrote:
> >
Thanks for your explanations.
> Oh, forgot to mention that on certain platforms (e.g. Linux at least
> in earlier versions of Gecko) .focus() doesn't work and I don't know a
> way around this.
Well, it depends on the behaviour of your windowmanager, and whether
you're trying to focus a content window in a build with L. David Baron's
first patch for his focus-stealing problem.
I found a bug in bugzilla where it was claimed this was what the Linux
users expect. I think it's dumb, like many other mozilla-on-linux
pecularities, but as long as I'm not forced to use Linux, I don't care
very much.
Nickolay