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

Locate the parent window of a javascript popup.

13 views
Skip to first unread message

Tony

unread,
Nov 20, 2009, 8:10:29 AM11/20/09
to
Hi,

var wm = Components.classes['@mozilla.org/appshell/window-mediator;
1'].getService(Components.interfaces.nsIWindowMediator);
var enumerator = wm.getEnumerator(null);
var retval = [];
while (enumerator.hasMoreElements()) {
retval.push(enumerator.getNext());
}
var wins = retval;

The above wins variable will contain an array of all the windows open.
Initially it will show 1 window object[object ChromeWindow] only.

Now go to this website http://www.w3schools.com/js/tryit_view.asp?filename=tryjs_alert
and click on the alert box.

Run the above command again and you will find wins array contains 2
ChromeWindow objects.
The alert window is a modal window.

Can anyone tell me how do i know what is the parent window of this
modal window?
other words - How do i find the parent window of the alert window?

My problem is ... i might have n number of windows open.
I will be working on a particular chrome window object.
Will do certain action on the chrome window object like click a
button, which might result in a javascript alert box or confirm dialog
which popups up.
I would like to handle this javascript popup that gets generated from
this chromewindow that iam working on only.
In other words i would like to get a hold of the javascript popup
object that was created from the parent window.

I cant seem to find any relation to the parent window from the
javascript popup object..

Can anyone help me on this ...

Thanks,
Tony

Tony

unread,
Nov 28, 2009, 1:49:41 AM11/28/09
to
Anybody , who can help .... ??


On Nov 20, 6:10 pm, Tony <ynot...@gmail.com> wrote:
> Hi,
>

> var wm = Components.classes['...@mozilla.org/appshell/window-mediator;


> 1'].getService(Components.interfaces.nsIWindowMediator);
> var enumerator = wm.getEnumerator(null);
> var retval = [];
> while (enumerator.hasMoreElements()) {
> retval.push(enumerator.getNext());}
>
> var wins = retval;
>
> The above wins variable will contain an array of all the windows open.
> Initially it will show 1 window object[object ChromeWindow] only.
>

> Now go to this websitehttp://www.w3schools.com/js/tryit_view.asp?filename=tryjs_alert

John J. Barton

unread,
Nov 29, 2009, 11:51:38 PM11/29/09
to
Tony wrote:
> Anybody , who can help .... ??
>
>
> On Nov 20, 6:10 pm, Tony <ynot...@gmail.com> wrote:
>> Hi,
>>
>> var wm = Components.classes['...@mozilla.org/appshell/window-mediator;
>> 1'].getService(Components.interfaces.nsIWindowMediator);
>> var enumerator = wm.getEnumerator(null);
>> var retval = [];
>> while (enumerator.hasMoreElements()) {
>> retval.push(enumerator.getNext());}
>>
>> var wins = retval;
>>
>> The above wins variable will contain an array of all the windows open.
>> Initially it will show 1 window object[object ChromeWindow] only.
>>
>> Now go to this websitehttp://www.w3schools.com/js/tryit_view.asp?filename=tryjs_alert
>> and click on the alert box.
>>
>> Run the above command again and you will find wins array contains 2
>> ChromeWindow objects.
>> The alert window is a modal window.
>>
>> Can anyone tell me how do i know what is the parent window of this
>> modal window?
>> other words - How do i find the parent window of the alert window?

I don't know about 'parent' but for the alert box Chromebug shows
window.opener is the w3schools site. There is documentation for opener on
https://developer.mozilla.org/en/DOM/window
but not on
https://developer.mozilla.org/en/XUL/window

jjb

Tony

unread,
Nov 30, 2009, 7:36:10 AM11/30/09
to
Hi John,

Thanks a lot, it worked ....
winobject.opener.document.location - gave me the parent link

Now can make out if the window was opened by which parent browser.

Thanks,
Tony


On Nov 30, 9:51 am, "John J. Barton" <johnjbar...@johnjbarton.com>
wrote:

0 new messages