Discussion in 'Javascript' started by Nadim Attari, Jun 28, 2004.

  1. Nadim Attari

    Nadim Attari Guest


    how can i know whether the surfer is closing the window (web browser) or he
    is moving from one page to another (e.g. by clicking a link or submitting a
    form...) ?

    nadim attari
    Nadim Attari, Jun 28, 2004
    1. Advertisements

  2. You can know if a user is navigating as a result of clicking a link or
    submitting a form on *your* page, by installing code on your pages that
    monitors such activity. Other activity; choosing a favourite/bookmark,
    typing a URL into the location bar, using any 'history' facility, back
    or forward buttons, dragging a web link onto the browser window, etc are
    not exposed to javascript and cannot be detected. So there is no way of
    knowing whether an onunload event is being triggered as a result of the
    user closing the browser or some other activity outside of the scope of
    a web page.

    Richard Cornford, Jun 28, 2004
    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.