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

Discussion in 'Javascript' started by Roy Wang, Nov 2, 2004.

  1. Roy Wang

    Roy Wang Guest

    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
     
    Roy Wang, Nov 2, 2004
    #1
    1. Advertisements

  2. Roy Wang

    rf Guest

    Roy Wang wrote
    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.
     
    rf, Nov 2, 2004
    #2
    1. Advertisements

  3. Roy Wang

    Roy Wang Guest

    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
     
    Roy Wang, Nov 3, 2004
    #3
  4. Roy Wang

    rf Guest

    This is doomed to failure, as I pointed out in the bits of my prior post
    that you failed to quote.
     
    rf, Nov 3, 2004
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.