473,666 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="docum ent.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 6958
Hi Laurent,

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

onUnLoad='opene r.tellTheServer ();';

3) This javascriptfunct ion 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="docum ent.location='. ...'", it doesn't send a request
to the web server when the user closes the popup.
`document.locat ion' has been deprecated a long time ago. Use
`window.locatio n'.
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="docum ent.location='. ...'", it doesn't send a request
to the web server when the user closes the popup.
`document.locat ion' has been deprecated a long time ago. Use
`window.locatio n'.
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
8565
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 problem) as I can just put a location.replace('http://www.mysite.com/html/logoff.jsp'); into the onUnload event of the page they always finish on. This should fire when they click the X in the corner (my app. is in a popup window) instead of hitting...
2
5647
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 exit buttons I have supplied but by clicking on the browser window top right X or closing it by clicking with the right mouse button on the tray icon for the window. Unfortunately it is also triggered by a refresh, which my web page does as part of...
6
15893
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 set with "window.onload=", the error comes up "permission denied to set property window.onunload"
3
3676
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 does. If, instead, I put this into frames it does call the alert:
2
1644
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 window that will open is a survey for a webcast they just viewed. I can't put the script in the header or place a onUnload command in the body tag. Only place I can put it is in the body of the page within a script file. Thanks a bunch!
1
1520
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" in the <scripttag. However, when I do that, it launches foo as soon as the page loads and does NOT launch when the page is unloaded.
0
11840
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 init() is a function which initialises some variables (for example).
0
8448
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.