Loading ...
Sorry, an error occurred while loading the content.

Prevent form closing

Expand Messages
  • benjackali
    Hi I m starting to work my way through YUI and I m getting to grips with most of it. I m hitting a problem however with preventing a window from closing.
    Message 1 of 3 , Jan 22, 2009
    View Source
    • 0 Attachment
      Hi

      I'm starting to work my way through YUI and I'm getting to grips with
      most of it.

      I'm hitting a problem however with preventing a window from closing.
      Basically I want to intercept the close event on the window, ask the
      user if they are sure and then close or not close accordingly.

      What I can't prevent is the window close event being processed even if
      I say stopEvent. Here's an extract of my code...

      YAHOO.util.Event.on(window, "unload", function(e) {
      alert("Not going to close"); // obviously this becomes a yes/no
      YAHOO.util.Event.stopEvent(e);
      /});

      Any ideas?

      Aidan
    • Adam Moore
      ... Try using the beforeunload event rather than the unload event. -Adam ... --
      Message 2 of 3 , Jan 22, 2009
      View Source
      • 0 Attachment
        On Fri, Jan 23, 2009 at 01:13:42AM -0000, benjackali wrote:
        > I'm starting to work my way through YUI and I'm getting to grips with
        > most of it.
        >
        > I'm hitting a problem however with preventing a window from closing.
        > Basically I want to intercept the close event on the window, ask the
        > user if they are sure and then close or not close accordingly.

        Try using the 'beforeunload' event rather than the 'unload' event.

        -Adam

        > What I can't prevent is the window close event being processed even if
        > I say stopEvent. Here's an extract of my code...
        >
        > YAHOO.util.Event.on(window, "unload", function(e) {
        > alert("Not going to close"); // obviously this becomes a yes/no
        > YAHOO.util.Event.stopEvent(e);
        > /});
        >
        > Any ideas?
        >
        > Aidan
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >

        --
      • benjackali
        Thanks Adam.
        Message 3 of 3 , Feb 1, 2009
        View Source
        • 0 Attachment
          Thanks Adam.
        Your message has been successfully submitted and would be delivered to recipients shortly.