changing opener

  • Thread starter Diana Coppenbarger
  • Start date
D

Diana Coppenbarger

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:eek:pener.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
 
D

DU

Diana said:
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:eek:pener.setDate()"
to set the date back on the main window.

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

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.


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
window and changing the month looks like:

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

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

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.
calWin.opener = this; // reset back to main window
}

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

alert(calWin.opener.location);
}

(The alerts were added for debugging.) This all works just fine in
IE

it does??

, 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

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

, but it doesn't seem to work. Does anyone have any
suggestions?

-Diana


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/doctorunclear/Netscape7/Netscape7Section.html
 
R

Richard Cornford

<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.
 
D

DU

Richard said:
<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

Yes... I totally missed that! Doh!

(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.

Well, it's a returned value which is never used.
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.

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/doctorunclear/Netscape7/Netscape7Section.html
 
D

Diana Coppenbarger

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
 
D

DU

Diana said:
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.

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.
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
--
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/doctorunclear/Netscape7/Netscape7Section.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top