Results 1 to 2 of 2

Thread: onBeforeUnload

  1. #1
    Join Date
    Dec 1969

    Default onBeforeUnload

    I&#039;m trying to implement something very similar to the article from this site on promting a user to save before they leave the page(http://aspnet.4guysfromrolla.com/articles/101304-1.aspx). I have changed the implementation a bit to accommodate what I need. My problem is when I set the onBeforeUnload event handler, like this: window.onBeforeUnload = myfunction(); it&#039;s seems to call myfunction() right then. Does anyone know why this happens?<BR><BR>Thanks, <BR>Jeremy

  2. #2
    Join Date
    Dec 1969

    Default RE: onBeforeUnload

    you want &#039;window.onBeforeUnload = myfunction;&#039; Using the parenthesis actually executes the function and assigns the return value to onBeforeUnload. You can also do window.onBeforeUnload = function (parameters) { &#060;blah&#062; }; if you need parameters going into the javascript function.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts