Do img.src assignment in page OnUnload event handler, Is it dangerous?

R

Roy Wang

Hi everyone,
I want to assign a url to the img.src attribute using javascript so
that browser will send a request according to the url, which is all i
want.

The tricky stuff is i want to do it in Page OnUnload event handler
which is called just before the browser is starting to unload the
document(ESPECIALLY when the user choose to close the browser window
to fire the event).

I use IIS6, IE6,Netscape 7.2, and Mozilla 1.7.3 to do the test.
By checking out IISlog, I find out they all properly logged the
ununload event by assigning to img.src, even when the browser is
directly closed.

So I want to make sure this approach is OK in the three browser i
used.
I think it's risky theoreticly.

Could anyone help me on this? OR tell me where I can get the insider
information.

Thanks a lot.
Roy
 
R

rf

Roy Wang wrote
The tricky stuff is i want to do it in Page OnUnload event handler

I assume this has something to do with cleaning up a server side process. If
so then it is doomed to failure. What if I merely switch my computer off/it
crashes/there is a power outage/the network fails?. Your onUnload event does
not fire.

What if I have javascript turned off?

Rethink your design so it does not matter what happens to the user, for
example use a session variable and time that out server side.
 
R

Roy Wang

The purpose is to send some data back to the server using
query string of the request.
But some data won't be collected or accurate unless they are sent whent
the page is exiting.

If javascript is disabled, then no data will be collected.
Thanks,
Roy
 
R

rf

Roy said:
The purpose is to send some data back to the server using
query string of the request.
But some data won't be collected or accurate unless they are sent whent
the page is exiting.

This is doomed to failure, as I pointed out in the bits of my prior post
that you failed to quote.
 

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,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top