5 Replies Latest reply on Jan 12, 2018 6:57 PM by -Max-

    How to customize the "Warn on unsaved" dialog?


      I'm using APEX 5.1.1. I have a interactive grid page with a return button, which simply redirects to another page. I have enabled "warn on unsaved" property on this button to alert the user for any unsaved changes. But, I would like to modify the default size of that error dialog and message with more user friendly message. any ideas are appreciated, thanks for your help.

        • 1. Re: How to customize the "Warn on unsaved" dialog?

          Hello Sgodavar


          The JavaScript function that drives the "Warn on Unsaved Changes" is apex.page.warnOnUnsavedChanges.

          You can get more details on it here.


          You can use the pMessage parameter to define a custom warning message. But as stated, not all browser will support this.

          In fact, most browser (Chrome, Edge, Firefox, Opera and Safari) removed support for custom message.

          Regarding the visual of the dialog, you can't change it since it's handled by the browser itself (just like the alert, confirm and prompt dialogs).


          So unfortunately, you can't do much about it.




          • 2. Re: How to customize the "Warn on unsaved" dialog?

            I've been trying to do this also and Max is right. The one that pops up by default isn't customizable, but I think going with a modal page pop up might work with a DA.

            • 3. Re: How to customize the "Warn on unsaved" dialog?

              Unfortunately a custom modal dialog wouldn't be the same as the warn on unsaved dialog.


              The warn on unsaved dialog is able to block/lock the browser.

              E.g. you change something and you close the browser. The warning message will prevent the browser from closing and display the warning dialog.

              A custom dialog wouldn't be able to prevent the browser from closing.




              • 4. Re: How to customize the "Warn on unsaved" dialog?


                A user can still close the browser with a warning message displayed.  It is not advisable but still very possible..


                Thank you,


                Tony Miller

                Los Alamos, NM

                • 5. Re: How to customize the "Warn on unsaved" dialog?



                  Since it's a browser feature, each could behave in a different way.


                  Most browsers will prevent you from closing the browser when the warning message is display (using the Warn on Unsaved feature).

                  Warn on Unsaved Changes.gif


                  From what I was able to test only Firefox allows closing the browser with the warning displayed.

                  It will display the warning and prevent the browser from closing. Then if the user tries to close the browser again it will close itself.

                  They will at least be warned beforehand.


                  So what I meant to say was that a custom solution (with a custom modal) that is not based on the onbeforeunload event wouldn't be able to prevent a browser from closing.


                  It could work perfectly fine with links within the application

                  But it wouldn't work with actions like the previous page button, closing the browser and such.