call a function on page close NOT unload

Discussion in 'Javascript' started by Donkey Cart Racer, Jul 5, 2006.

  1. Hi,

    I have a page - page1 which opens a window1 where users can look at
    tasks, in window1 users can click and open window2 where they can
    create new tasks


    I want to refresh window1 when window2 closes
    and refresh page1 when window 1 closes


    Currently i am calling a javascript function on unload which refreshes
    window.opener.location
    the problem i am having is that when window2 closes it unloads itself
    and calls refresh on window1 which unloads itself on refresh and hence
    refreshes page1


    I do not want to refresh page1 when window2 closes only if window1
    closes. I hope this makes sense


    Is there anyway i can differenciate between unload and a page close?
    because unload gets called on refresh also, and i would like to only
    take actions when a page closes not wen it unloads


    thanks
    B
     
    Donkey Cart Racer, Jul 5, 2006
    #1
    1. Advertising

  2. Hi,

    Donkey Cart Racer wrote:
    > Hi,


    [snip]

    > Is there anyway i can differenciate between unload and a page close?
    > because unload gets called on refresh also, and i would like to only
    > take actions when a page closes not wen it unloads
    >
    >
    > thanks
    > B


    No, there is no way to differentiate between an onunload even when the
    page refreshes, or when it gets closed. For the page, it's the same.

    However, if window1 has a reference on window2, you can check if the
    window is closed, and take appropriate action.

    You can get a reference on another window either when you open it:

    var myWindow2 = window.open( , [NAME], [FEATURES] ); and then: ...en in Calcutta: http://www.calcutta-espoir.ch
     
    Laurent Bugnion, Jul 5, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mariella Bakker
    Replies:
    1
    Views:
    5,260
    John Timney \( MVP \)
    May 8, 2006
  2. lander
    Replies:
    5
    Views:
    2,610
    Mark Rae [MVP]
    Mar 3, 2008
  3. Iñaki Baz Castillo
    Replies:
    7
    Views:
    950
    Iñaki Baz Castillo
    Jan 12, 2010
  4. Al Fraser

    Browser Close / New URL / Form UnLoad()

    Al Fraser, Sep 30, 2003, in forum: Javascript
    Replies:
    1
    Views:
    209
    David Dorward
    Sep 30, 2003
  5. DonO

    unload for close not refresh

    DonO, Mar 2, 2004, in forum: Javascript
    Replies:
    2
    Views:
    148
Loading...

Share This Page