How to customize onbeforeunload confirm box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pranabpiitk
    New Member
    • Mar 2008
    • 3

    #1

    How to customize onbeforeunload confirm box

    Hi,
    I want to customize the onbeforeunload confirm box,I need to write my own message instead of default message.

    Can anyone help me...????
  • Logician
    New Member
    • Feb 2007
    • 210

    #2
    Originally posted by pranabpiitk
    Hi,
    I want to customize the onbeforeunload confirm box,I need to write my own message instead of default message.

    Can anyone help me...????
    You can't remove the standard text, but you can insert text:
    Code:
    window.onbeforeunload = function (evt)
    {
     var message = '!! Leaving this page may cause loss of data !!\n';
     
          if (typeof evt == 'undefined') 
        evt = window.event;
    
           if (evt)
               evt.returnValue = message;
     
       return message; 
     }

    Comment

    • zachgotnosauce
      New Member
      • Jun 2008
      • 1

      #3
      Hi, did you get any answer to this? As I look at it, it doesn't seem to be possible. But I am very curious. Let me know.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Welcome to Bytes. Your question has already been answered. You can add your own message but you can't remove the default message.

        Comment

        Working...