Connecting Tech Pros Worldwide Forums | Help | Site Map

Opera - .closed not accessible if window is closed?

Matt Kruse
Guest
 
Posts: n/a
#1: Jul 20 '05
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...)

andy johnson
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Opera - .closed not accessible if window is closed?


On 7 Sep 2003 15:18:28 -0700, matt@mattkruse.com (Matt Kruse) wrote:
[color=blue]
>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...)[/color]

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)
Matt Kruse
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Opera - .closed not accessible if window is closed?


"andy johnson" <andrew.johnson@chicagonet.net> wrote:[color=blue]
> 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.[/color]

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.
[color=blue]
> From a users point of view, Opera is pretty good, and definitely
> a good alternative to the crap microsoft puts out.[/color]

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



Dave Griffiths
Guest
 
Posts: n/a
#4: Jul 20 '05

re: Opera - .closed not accessible if window is closed?


On Sun, 07 Sep 2003 23:36:03 +0000, Matt Kruse wrote:
[color=blue]
> "andy johnson" <andrew.johnson@chicagonet.net> wrote:[color=green]
>> 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.[/color]
>
> 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.
>[color=green]
>> From a users point of view, Opera is pretty good, and definitely a good
>> alternative to the crap microsoft puts out.[/color]
>
> 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[/color]

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>
Matt Kruse
Guest
 
Posts: n/a
#5: Jul 20 '05

re: Opera - .closed not accessible if window is closed?


"Dave Griffiths" <dave@daveg.co.uk> wrote:[color=blue]
> 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()
> }[/color]

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


Richard Cornford
Guest
 
Posts: n/a
#6: Jul 20 '05

re: Opera - .closed not accessible if window is closed?


"Matt Kruse" <newsgroups@mattkruse.com> wrote in message
news:6I97b.394629$YN5.261425@sccrnsc01...
<snip>[color=blue]
>This is basically exactly what I'm doing, and what fails in Opera7,[/color]
when[color=blue]
>the domain of the popped up window is not the same as the opener.[/color]

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.


Closed Thread