Gecko DOM window onclose event ?

  • Thread starter Luke Matuszewski
  • Start date
L

Luke Matuszewski

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 :)...
 
T

Thomas 'PointedEars' Lahn

Danny said:
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
 
L

Luke Matuszewski

Thomas 'PointedEars' Lahn napisal(a):
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>
 
T

Thomas 'PointedEars' Lahn

Luke said:
Thomas 'PointedEars' Lahn napisal(a):

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
 
L

Luke Matuszewski

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/DOM:window#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
 
T

Thomas 'PointedEars' Lahn

Luke said:
Thomas 'PointedEars' Lahn napisal(a):

Probably thats why it is colored red on
http://developer.mozilla.org/en/docs/DOM:window#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.
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
 

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,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top