onunload and redirect

L

Laurent

I am trying to use the onunload event to know when the user closes a
popup by receiving a request on the web server.

I have a main page from where the user opens a popup. What I want is
when the user closes the popup, it sends a request to my web server
(GoAhead) using the onunload event, then closes the popup.

For the moment, this what i have: when the user closes the popup, I
use the onunload event to open a different popup (by this way, I get a
request on the web server and I know that the user closes the first
popup), then, this new popup closes itself with the onload event. It
is working but having this second popup opening and closing is not
very neat.

If I try to change the location of the first popup in the onunload
event: onunload="document.location='....'", it doesn't send a request
to the web server when the user closes the popup.

Is there a way to send a request to the webserver when the user closes
the popup without the need to have an extra popup opened and closed ?

The web server I am using is working on a pseudo "cgi" mode called
"goforms", it avoids to create a different process for each request.
With "goforms", each request is handled by a unique process which is
always running.

Laurent
 
E

Erwin Moller

Hi Laurent,

Try this:
1) On you mainpage: create a hidden frame (size=0 and such)
2) Your pop-up calls a javascriptfunction in the mainframe when closed, then
closes.

onUnLoad='opener.tellTheServer();';

3) This javascriptfunction loads the page you want in the hidden frame.

Regards,
Erwin Moller
 
T

Thomas 'PointedEars' Lahn

Laurent said:
I am trying to use the onunload event to know when the user closes a
popup by receiving a request on the web server.

Unless you can *guarantee* that the user cannot navigate to another
document within the popup, this is not a viable solution as the onunload
event will fire then, too. And you cannot guarantee this, unless this
is for a very restricted Intranet. There is the `onclose' event handler
in the IE DOM, but the same restriction applies here.
I have a main page from where the user opens a popup. What I want is
when the user closes the popup, it sends a request to my web server
(GoAhead) using the onunload event, then closes the popup.

What if client-side scripting is disabled or not even present?
For the moment, this what i have: when the user closes the popup, I
use the onunload event to open a different popup (by this way, I get a
request on the web server and I know that the user closes the first
popup),

You cannot know for sure, unless ... (see above).
If I try to change the location of the first popup in the onunload
event: onunload="document.location='....'", it doesn't send a request
to the web server when the user closes the popup.

`document.location' has been deprecated a long time ago. Use
`window.location'.
Is there a way to send a request to the webserver when the user closes
the popup without the need to have an extra popup opened and closed ?

There is a way to send a request to the Web server if the `unload' event
fires (or on any other occasion). It is called XML HTTP Request and
implemented with the XMLHttpRequest object in the Gecko DOM and the
XMLHTTPRequest ActiveX object in IE for Windows. This DOM object allows
for synchronous requests, that is, you can wait for the request to be
answered positive and then let the UA close the popup window. Whether
either approach is a viable solution depends on your client system
requirements and network environment. Ask Google (Groups) for details.
The web server I am using is working on a pseudo "cgi" mode called
"goforms", it avoids to create a different process for each request.
With "goforms", each request is handled by a unique process which is
always running.

You should really rethink the design of your Web application.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Laurent said:
I am trying to use the onunload event to know when the user closes a
popup by receiving a request on the web server.

Unless you can *guarantee* that the user cannot navigate to another
document within the popup, this is not a viable solution as the onunload
event will fire then, too. And you cannot guarantee this, unless this
is for a very restricted Intranet. And IIRC there is a undocumented
`onclose' event handler in the IE DOM that fires only when a window
is closed, but the same restriction would apply here.
I have a main page from where the user opens a popup. What I want is
when the user closes the popup, it sends a request to my web server
(GoAhead) using the onunload event, then closes the popup.

What if client-side scripting is disabled or not even present?
For the moment, this what i have: when the user closes the popup, I
use the onunload event to open a different popup (by this way, I get a
request on the web server and I know that the user closes the first
popup),

You cannot know for sure, unless ... (see above).
If I try to change the location of the first popup in the onunload
event: onunload="document.location='....'", it doesn't send a request
to the web server when the user closes the popup.

`document.location' has been deprecated a long time ago. Use
`window.location'.
Is there a way to send a request to the webserver when the user closes
the popup without the need to have an extra popup opened and closed ?

There is a way to send a request to the Web server if the `unload' event
fires (or on any other occasion). It is called XML HTTP Request and
implemented with the XMLHttpRequest object in the Gecko DOM and the
XMLHTTPRequest ActiveX object in IE for Windows. This DOM object allows
for synchronous requests, that is, you can wait for the request to be
answered positive and then let the UA close the popup window. Whether
either approach is a viable solution depends on your client system
requirements and network environment. Ask Google (Groups) for details.
The web server I am using is working on a pseudo "cgi" mode called
"goforms", it avoids to create a different process for each request.
With "goforms", each request is handled by a unique process which is
always running.

You should really rethink the design of your Web application.


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

Similar Threads

iframe onunload 0
onunload issues 1
Popup HTML help 5
Body OnUnload ASP.NET Postback question 2
How to discover a CSS Selector name? 8
onunload 1
A Server call using onUnload 2
Javascript redirect 1

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top