onunload and a couple of things...

R

Ric Castagna

I have a form that I'm trying to handle if the viewer "leaves" without
completing the entire thing.

The client wants to be advised that someone one "tried" to fill out
the application. Most likely situation will be the viewer will click
on another link in the site, or enter a new address into the browser.

I've got the onunload() raising an alert box, so I think I can get it
to do the processing that I want it to.

Here's my problem...I need to know if there's a way to detect the URL
that was entered into the address bar or clicked via a link. This way
I can do the processing I need to and then send them to their desired
destination.

Help!

Thanks in advance,
Ric
 
G

Greg

As far as I know, this isn't an option.

When a person clicks on a link in a web-browser, this sends a GET
request to the server that link points to, and the document that is
returned replaces the current document and is processed. So if I'm on
your website, and I click on a link to www.slashdot.org The slashdot
server sees my request, but yourwebsite doesn't know where I went.

I could be wrong, but I think this is the way it works.

;-) you could always pop up a form that asks them where they are
going... ;-)

I think you can allow a cancellation of their exit, via an "are you
sure?" type dialogue, which could cancel their action, while I've
observed these, I haven't implemented this.

Hope that is helpful.
Greg.
www.greentreesoftware.ca
 
E

Egbert Beuker

Maybe you can put a hidden form AND a hidden frame in the page.

On the onunload event you submit the form to the framehandler page, target
is the iframe, and the page will then navigate to the URL requested by the
user!

<form id="myHiddenForm" action="formhandler.asp" target="myHiddenFrame">
[info to post]
</form>

<iframe id="myHiddenFrame" name="myHiddenFrame"></iframe>

function window_onunload()
{
myHiddenForm.submit();
}

(never tried this, but i think it might work!)
 
I

Ian Hobson

Ric said:
I have a form that I'm trying to handle if the viewer "leaves" without
completing the entire thing.

The client wants to be advised that someone one "tried" to fill out
the application. Most likely situation will be the viewer will click
on another link in the site, or enter a new address into the browser.

I've got the onunload() raising an alert box, so I think I can get it
to do the processing that I want it to.

Here's my problem...I need to know if there's a way to detect the URL
that was entered into the address bar or clicked via a link. This way
I can do the processing I need to and then send them to their desired
destination.
It is a while since I tested this area, but this is what I found, (from
memory). I was only using IE and late NS.

a) The onunload event will not always be called, (close window) so the
lack of clear up must not permanently capture resources.

b) If you have another window or panel/layer open, you can get that to
do the clear up, and leave the original window to go where the user
wanted it to go.

Regards

Ian
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top