Window close event

Discussion in 'JavaScript' started by bighippo, Sep 10, 2008.

  1. #1
    Hi,

    Does anyone knows a workaround to this problem.

    I made a javascript that will pop up a chat window when i close the window. The problem is the chat window pops up every time it unloads the page.

    I used window.onbeforeunload function to trigger the function.. Is it possible to call the function only when i press the X icon (close button in title bar)? the function must not be called every time i click submit button. If you know a work around please please help me thanks :)

    cheers.
     
    bighippo, Sep 10, 2008 IP
  2. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    function fnCallback(e) {
     // put code here to show popup
    } 
    YAHOO.util.Event.addListener("elementid", "click", fnCallback); 
    
    Code (markup):
    http://developer.yahoo.com/yui/event/
     
    LogicFlux, Sep 10, 2008 IP