By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,681 Members | 1,864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,681 IT Pros & Developers. It's quick & easy.

Gecko DOM window onclose event ?

P: n/a
As in topic... has anyone used it ?

I tried to use it but i guess i failed... here is a code:

<html>
<head>
<title></title>
<script type="text/javascript">
function closedWin() {
confirm("close ?");
return false; /* which will not allow to close the window */
}
if(window.addEventListener) {
window.addEventListener("close", closedWin, false);
}

window.onclose = closedWin;
</script>
</head>
<body>

</body>
</html>

Please try and lighten me :-)...

Dec 3 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

is not .onclose, is .onunload :).

Danny
Dec 4 '05 #2

P: n/a
Danny wrote:
is not .onclose, is .onunload :).


It is well known that the `unload' event also fires when the document is
unloaded, i.e. when the location changes. Please get informed before you
try to help here.
PointedEars
Dec 4 '05 #3

P: n/a

Thomas 'PointedEars' Lahn napisal(a):
Danny wrote:
is not .onclose, is .onunload :).
It is well known that the `unload' event also fires when the document is
unloaded, i.e. when the location changes. Please get informed before you
try to help here.


Yes.
Question in topic refers to my older post on How to detect that a user
closes a user agent window - where i suggested the spying popup which
examines window.opener (window.opener.closed) properties.
I ask about onclose, because i wanted to attach that event on Gecko
browsers - and further if such attach will work i could disable spying
popup - all necessery logout via img.src will be done in onclose event
and not in spying popup (so questions from users of Gecko browsers in
style: "Why this popup shows and quickly closes when i click/write/go
to another ulr ?" will probably never rise... only from IE users).

Still waitin for answer on topic question...

PS i tried to open window in JS (popup via window.open) and added to
returned reference the event onclose... closed the opened window but
onclose was not fired :(
[code]
<html>
<head>
<title></title>
<script type="text/javascript">
function testingPopup(evt) {
spyWin = window.open('page2.html','testing',
'width=100,height=100,left=100,top=0,status=0');
spyWin.addEventListener("close", closedWin, false);
spyWin.onclose = closedWin;
}
function closedWin() {
confirm("close ?");
return false;
}
if(window.attachEvent) {
window.attachEvent("onunload", testingPopup);
} else {
if(window.addEventListener) {
window.addEventListener("unload", testingPopup, false);
} else {
window.onunload = testingPopup;
}
}

</script>
</head>
<body>

</body>
</html>



PointedEars


Dec 4 '05 #4

P: n/a
Luke Matuszewski wrote:
Thomas 'PointedEars' Lahn napisal(a):
Danny wrote:
> is not .onclose, is .onunload :).
It is well known that the `unload' event also fires when the document is
unloaded, i.e. when the location changes. Please get informed before you
try to help here.


Yes.
Question in topic refers to my older post


Threads should be continued if the subject virtually is the same.
on How to detect that a user closes a user agent window - where i
suggested the spying popup which examines window.opener
(window.opener.closed) properties. I ask about onclose, because i
wanted to attach that event on Gecko browsers
1. `onclose' is not an event, it is an event handler. The respective event
would be named `close'. However, there is of course no such event in
W3C DOM Level 2 Events (or the Working Group Note on DOM Level 3 Events),
so using addEventListener() is not very likely to work in the first
place.

2. You cannot add previously unsupported event handlers to the implemented
DOM.

3. The Gecko DOM appears to support such an event handler:

<URL:http://developer.mozilla.org/en/docs/DOM:window#Event_Handlers>

Historically, event handlers can be assigned event listeners with
assignment of a Function object reference to the respective property
of the target object. However, it is not described that returning a
false-value will cancel the respective event.
PS i tried to open window in JS (popup via window.open) and added to
returned reference the event onclose... closed the opened window but
onclose was not fired :(


So, ignoring that your examples were not Valid HTML, the event handler
appears not to be supported yet or not longer to be supported in the
Gecko DOM.

Would you please learn to quote?
PointedEars
Dec 4 '05 #5

P: n/a

Thomas 'PointedEars' Lahn napisal(a):
So, ignoring that your examples were not Valid HTML, the event handler
appears not to be supported yet or not longer to be supported in the
Gecko DOM.

Probably thats why it is colored red on
http://developer.mozilla.org/en/docs...Event_Handlers
, but it makes no excuse for them to inform developer that 'red' events
are not supported. This is my assumption, but maybe someone more
knowing will lighten the 'red' events.
Would you please learn to quote?
Looks good here ?
PointedEars


Luke

Dec 4 '05 #6

P: n/a
Luke Matuszewski wrote:
Thomas 'PointedEars' Lahn napisal(a):
So, ignoring that your examples were not Valid HTML, the event handler
appears not to be supported yet or not longer to be supported in the
Gecko DOM.
Probably thats why it is colored red on
http://developer.mozilla.org/en/docs...Event_Handlers


It is possible, but not very likely. That is a Wiki and links colored
different there indicate links to documents that have not been written yet.
, but it makes no excuse for them to inform developer that 'red'
events are not supported. This is my assumption, but maybe someone
more knowing will lighten the 'red' events.


You have yet to understand what a Wiki is. Click the link.
Would you please learn to quote?


Looks good here ?


No. Signatures (literal and technical meaning) are not to be quoted unless
one referrs to them directly. And _all_ quoted material that has no direct
reference should be removed from the followup before it is posted.
PointedEars
Dec 4 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.