Opera - .closed not accessible if window is closed?

M

Matt Kruse

See: http://www.mattkruse.com/temp/window_closed.html

It looks like the .closed property of a window is inaccessible if the
window is actually closed. Other browsers have no problem detecting
that the window has been closed. Opera 7.11 and 7.20b7 both throw
errors when trying to check the .closed property.

Is this a bug in Opera, or do I have to (once again) take special
action to make normal javascript work with Opera?

Matt Kruse
(who still finds very few redeeming qualities in Opera...)
 
A

andy johnson

See: http://www.mattkruse.com/temp/window_closed.html

It looks like the .closed property of a window is inaccessible if the
window is actually closed. Other browsers have no problem detecting
that the window has been closed. Opera 7.11 and 7.20b7 both throw
errors when trying to check the .closed property.

Is this a bug in Opera, or do I have to (once again) take special
action to make normal javascript work with Opera?

Matt Kruse
(who still finds very few redeeming qualities in Opera...)

From what I understand about the design philosophy of Opera, that is
so you won't pop up another annoying pop up in someones face. Cruising
the Opera forums, newsgroups, KB and bug reports will tell you for
sure. From a users point of view, Opera is pretty good, and definitely
a good alternative to the crap microsoft puts out.

Andy
-
"There would be a lot more civility in this world if people
didn't take that as an invitation to walk all over you"
- (Calvin and Hobbes)
 
M

Matt Kruse

andy johnson said:
From what I understand about the design philosophy of Opera, that is
so you won't pop up another annoying pop up in someones face. Cruising
the Opera forums, newsgroups, KB and bug reports will tell you for
sure.

unfortunately, I can't find any mention of this anywhere. I'm still
looking...
I think the correct behavior should be, if my script created the window,
then my script should be able to check if it's closed, regardless of what is
being displayed in it at the time.

Mozilla used to have this same bug, and they fixed it to let .closed be
visible to any code, regardless of security.
From a users point of view, Opera is pretty good, and definitely
a good alternative to the crap microsoft puts out.

It's all a metter of personal preferences. I've disliked every version of
Opera I've tried, and I've liked IE since version 5. I've been testing and
using browsers since mosaic came out, and I think IE6 is the best of any one
I've seen :)

Matt
 
D

Dave Griffiths

unfortunately, I can't find any mention of this anywhere. I'm still
looking...
I think the correct behavior should be, if my script created the window,
then my script should be able to check if it's closed, regardless of
what is being displayed in it at the time.

Mozilla used to have this same bug, and they fixed it to let .closed be
visible to any code, regardless of security.


It's all a metter of personal preferences. I've disliked every version
of Opera I've tried, and I've liked IE since version 5. I've been
testing and using browsers since mosaic came out, and I think IE6 is the
best of any one I've seen :)

Matt

Hi Matt

I am no expert here, just learning the language but remember an exercise I
did in my book on this subject. Here is the full code of the exercise, it
creates a window then takes care of all browsers and how to check if the
window has been closed by either the code or the user, if the window has
been closed it will open the same window then close it again, then there
are no errors. Take a look it might help, you might be able to adapt some
of it to your advantage.

Hope it helps
DaveG


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"> <HTML>
<HEAD>
<TITLE>window.closed Property</TITLE> <SCRIPT LANGUAGE="JavaScript">
// initialise global var for new window object // so it can be accessed
by all funtions on the page. var newWind

// set flag to help out with special handling for window closing var
isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false

// make new window and put some stuff in it. function newWindow() {
var output = ""
newWind = window.open("", "subwindow", "HEIGHT=200, WIDTH=200")

// taking care of navigator 2
if (newWind.opener == null) {
newWind.openern = window
}
}
output += "<HTML><BODY><H1>A sub-window</H1>" output += "<FORM><INPUT
TYPE='button' VALUE='Close Main Window'
onClick='window.opener.close()'></FORM></BODY></HTML>"
newWind.document.write(output)
newWind.document.close()


}
// close subwindow, including ugly workaround for IE3 function
closeWindow() {
if (isIE3) {
// if window is already open, nothing appears to happen // but if not,
the subwndow flashes momentarily (ahhh) newWind = window.open("",
"subwindow", "HEIGHT=200, WIDTH=200")
}
if (newWind && !newWind.closed) {
newWind.close()
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="button" VALUE="Open Window" onClick="newWindow()"><BR>
<INPUT TYPE="button" VALUE="Close it if still open"
onClick="closeWindow()">
</FORM>
</BODY>
</HTML>
 
M

Matt Kruse

Dave Griffiths said:
I am no expert here, just learning the language but remember an exercise I
did in my book on this subject. Here is the full code of the exercise
...
if (newWind && !newWind.closed) {
newWind.close()
}

This is basically exactly what I'm doing, and what fails in Opera7, when the
domain of the popped up window is not the same as the opener.
:(

Matt Kruse
 
R

Richard Cornford

This is basically exactly what I'm doing, and what fails in Opera7, when
the domain of the popped up window is not the same as the opener.

In theory, one horrible hackish quick fix would be to have the pop-up
load a frameset page form your domain and then have that frameset load
the page from the other domain. That should leave the new window object
accessible to your scripts.

Given the choice I would go for loosing the pop-up in preference.

Richard.
 

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

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top