Connecting Tech Pros Worldwide Help | Site Map

changing opener

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 11:00 AM
Diana Coppenbarger
Guest
 
Posts: n/a
Default changing opener

Hi,

I have a calendar program that is popped up by a HTML so that the user
can choose a specific date to be filled in via javascript from the
calendar program. I am using window.open() to start the calendar
program and then calling my own function "javascript:opener.setDate()"
to set the date back on the main window. This all works fine if I use
the current month that is displayed, but as soon as I have to rebuild
the calendar because they want to go to another month, the opener is
not being set correctly. The javascript for popping up the calendar
window and changing the month looks like:

function popupCal
{
calWin = window.open('/cgi-script/calWin','calWin');
}

function changeMonth(month)
{
calWin.open('/cgi-script/calWin'+month,'calWin');
alert(calWin.opener.location);
if(calWin.opener == calWin){
calWin.opener = this; // reset back to main window
}
alert(calWin.opener.location);
}

(The alerts were added for debugging.) This all works just fine in
IE, but when trying from Netscape 7.1 or Mozilla, the calWin.opener is
not reset and the alert says the calWin.opener.location is the same as
the calWin.location. Everything I have read about opener says you can
reset it like this, but it doesn't seem to work. Does anyone have any
suggestions?

-Diana

  #2  
Old July 20th, 2005, 11:01 AM
DU
Guest
 
Posts: n/a
Default Re: changing opener

Diana Coppenbarger wrote:[color=blue]
> Hi,
>
> I have a calendar program that is popped up by a HTML so that the user
> can choose a specific date to be filled in via javascript from the
> calendar program. I am using window.open() to start the calendar
> program and then calling my own function "javascript:opener.setDate()"
> to set the date back on the main window.[/color]

http://jibbering.com/faq/#FAQ4_24

This all works fine if I use[color=blue]
> the current month that is displayed, but as soon as I have to rebuild
> the calendar because they want to go to another month, the opener is
> not being set correctly.[/color]


Please elaborate on "the opener is not being set correctly". What do you
mean? Are you saying that the date is not pasted into some input field
in the opener?
Can you provide an url of your page? That would be so convenient here.

The javascript for popping up the calendar[color=blue]
> window and changing the month looks like:
>
> function popupCal
> {
> calWin = window.open('/cgi-script/calWin','calWin');
> }[/color]

I would set explicitly this calWin as a global variable.
[color=blue]
>
> function changeMonth(month)
> {
> calWin.open('/cgi-script/calWin'+month,'calWin');
> alert(calWin.opener.location);
> if(calWin.opener == calWin){[/color]

The boolean conditional expression should always be false. Immediately
after creating a secondary window, you're querying if the opener is a
pointer reference to the one of its own secondary window. So, that
should always be false.
[color=blue]
> calWin.opener = this; // reset back to main window
> }[/color]

This sort of assignment will (soon?) become impossible to do once
browsers tighten their security. Fooling around with pointers like that
shouldn't be possible. E.g.: Mozilla: NS_ERROR_XPC_BAD_CONVERT_JS

[color=blue]
> alert(calWin.opener.location);
> }
>
> (The alerts were added for debugging.) This all works just fine in
> IE[/color]

it does??

, but when trying from Netscape 7.1 or Mozilla, the calWin.opener is[color=blue]
> not reset and the alert says the calWin.opener.location is the same as
> the calWin.location. Everything I have read about opener says you can
> reset it like this[/color]

Ok, then. Please show me the links, references, documentation,
preferably official documentations.

, but it doesn't seem to work. Does anyone have any[color=blue]
> suggestions?
>
> -Diana[/color]


Best is to start by provide an url to your page.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

  #3  
Old July 20th, 2005, 11:01 AM
Richard Cornford
Guest
 
Posts: n/a
Default Re: changing opener

"DU" <drunclear@hot-R-E-M-O-V-E-mail.com> wrote in message
news:blvq5s$5m$1@news.eusc.inter.net...
<snip>[color=blue][color=green]
>> function changeMonth(month)
>> {
>> calWin.open('/cgi-script/calWin'+month,'calWin');[/color][/color]
<snip>

It is probably pertinent that this statement has no assignment. If we
assume that a global variable called "calWin" has been assigned a
reference to a pop-up window at this point and the above statement calls
the open method of that window in order to open another window (and I
cannot see any reason for doing that as this window has a perfectly good
wiondow.open function of its own (subject to browser support and content
inserting proxies)), then the window reference for this new pop-up is
just being discarded.

In principal neither calWin nor it's opener will be effected in any way
by this operation and the second pop-up window is inaccessible form
either this window or the first - calWin - pop-up as neither hold a
reference to it.

Richard.


  #4  
Old July 20th, 2005, 11:01 AM
DU
Guest
 
Posts: n/a
Default Re: changing opener

Richard Cornford wrote:[color=blue]
> "DU" <drunclear@hot-R-E-M-O-V-E-mail.com> wrote in message
> news:blvq5s$5m$1@news.eusc.inter.net...
> <snip>
>[color=green][color=darkred]
>>>function changeMonth(month)
>>>{
>>> calWin.open('/cgi-script/calWin'+month,'calWin');[/color][/color]
>
> <snip>
>
> It is probably pertinent that this statement has no assignment. If we
> assume that a global variable called "calWin" has been assigned a
> reference to a pop-up window at this point and the above statement calls
> the open method of that window in order to open another window[/color]

Yes... I totally missed that! Doh!

(and I[color=blue]
> cannot see any reason for doing that as this window has a perfectly good
> wiondow.open function of its own (subject to browser support and content
> inserting proxies)), then the window reference for this new pop-up is
> just being discarded.
>[/color]

Well, it's a returned value which is never used.
[color=blue]
> In principal neither calWin nor it's opener will be effected in any way
> by this operation and the second pop-up window is inaccessible form
> either this window or the first - calWin - pop-up as neither hold a
> reference to it.
>
> Richard.
>
>[/color]

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

  #5  
Old July 20th, 2005, 11:01 AM
Diana Coppenbarger
Guest
 
Posts: n/a
Default Re: changing opener

I am a bit new at javascript, so I apologize if I seem to not know
what I am doing. Here is a link to the script in question:

http://www.lle.rochester.edu/~dcop/calendarTest.html.

Click on the picture of the calendar to run the script and then click
on one of the arrows to change to a different month. Once you are in
the different month, if you are running in Netscape or Mozilla, it all
stops working.

When I type "javascript:", it says the functions are not defined.
Please note that the debugging alerts are not included in this link.

-Diana


DU <drunclear@hot-R-E-M-O-V-E-mail.com> wrote in message news:<bm071d$57e$1@news.eusc.inter.net>...[color=blue]
> Richard Cornford wrote:[color=green]
> > "DU" <drunclear@hot-R-E-M-O-V-E-mail.com> wrote in message
> > news:blvq5s$5m$1@news.eusc.inter.net...
> > <snip>
> >[color=darkred]
> >>>function changeMonth(month)
> >>>{
> >>> calWin.open('/cgi-script/calWin'+month,'calWin');[/color]
> >
> > <snip>
> >
> > It is probably pertinent that this statement has no assignment. If we
> > assume that a global variable called "calWin" has been assigned a
> > reference to a pop-up window at this point and the above statement calls
> > the open method of that window in order to open another window[/color]
>
> Yes... I totally missed that! Doh!
>
> (and I[color=green]
> > cannot see any reason for doing that as this window has a perfectly good
> > wiondow.open function of its own (subject to browser support and content
> > inserting proxies)), then the window reference for this new pop-up is
> > just being discarded.
> >[/color]
>
> Well, it's a returned value which is never used.
>[color=green]
> > In principal neither calWin nor it's opener will be effected in any way
> > by this operation and the second pop-up window is inaccessible form
> > either this window or the first - calWin - pop-up as neither hold a
> > reference to it.
> >
> > Richard.
> >
> >[/color]
>
> DU[/color]
  #6  
Old July 20th, 2005, 11:02 AM
DU
Guest
 
Posts: n/a
Default Re: changing opener

Diana Coppenbarger wrote:[color=blue]
> I am a bit new at javascript, so I apologize if I seem to not know
> what I am doing. Here is a link to the script in question:
>
> http://www.lle.rochester.edu/~dcop/calendarTest.html.
>[/color]

File not found!
I had the chance to examine the file though before it went off line. I
am convinced you do not need server-side interaction to create that
[previous or next] month calendar grid. Client-side script will suffice.

The
function changeMonth(month)
should be in the
cgi-script/calWin
file instead of its opener. Accessing that function from the opener just
makes things unneedlessly more complex, I think. Anyway, I'm sure your
interactive date/calendar picker can be made with only client-side script.
[color=blue]
> Click on the picture of the calendar to run the script and then click
> on one of the arrows to change to a different month. Once you are in
> the different month, if you are running in Netscape or Mozilla, it all
> stops working.
>
> When I type "javascript:", it says the functions are not defined.
> Please note that the debugging alerts are not included in this link.
>
> -Diana
>
>[/color]

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.