473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

onunload and redirect

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
Jul 23 '05 #1
3 6937
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
Jul 23 '05 #2
Laurent wrote:
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
Jul 23 '05 #3
Laurent wrote:
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
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andoni | last post by:
Hi, I am only writing for IE 5.5+ so no need for compatibility at all ;-) I am trying to get my users to logoff which they finish on a particular page. This is no problem (or should be no...
2
by: Simon Wigzell | last post by:
I'm using OnUnLoad in my body statement to redirect to a function to clean things up if someone exits a form by closing it from outside the webpage code - e.g. by not using the cancel or save and...
6
by: kaeli | last post by:
Hey guys, This error occurs ONLY in Netscape 7.0. Not in 7.1. So, I think it's a bug. Buuuut... Has anyone had this problem or know of a fix? When attempting to have an onunload function...
3
by: Andrew Poulos | last post by:
In a frameset I have this: window.onload = function() { frames.onunload = function() { alert('I'm going now'); } } when frames unloads I'm expecting the alert to be called but it never...
2
by: Rich | last post by:
Is there any way to get the same effect that the body tag onUnload creates. I need a script that will be placed in the body of the html that will open a new window when the parent is closed. The...
1
by: Tim Arview | last post by:
Hi, I'm trying to create an exit popup that doesn't require anything added to the body tag. In other words, I don't want to say <body onunload="foo">. I just want to have window.onunload="foo"...
0
acoder
by: acoder | last post by:
Problem onload and onunload events do not fire when going back, forward or refreshing the page Browser Opera Example Any code using onload or onunload, e.g. window.onload = init; where...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.