Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
365
beforeunload, stop user from switching tabs
posted

I have a page that has a  webtab control with 2 tabs. On the unload  I have a prompt to alert the users that they have data unsaved when unload is called.

 jQuery(window).bind('beforeunload', function(e) {
      
        return "Unsaved data."
       
       
         });

If you switch tabs and  click on stay on this page the tab index still changes and the new tab does not load. Is there a way to restore the tabs to the original state before unload was called?

Parents
  • 37874
    Verified Answer
    posted

    Hi dan2012a,

    I suggest that you handle the SelectedIndexChanging client-side event and cancel it if the user choose certain option:

            function SelectedIndexChangingdHandler(sender, eventArgs) {

                var a = confirm("Unsaved data! Continue?");

                if (!a) {

                    eventArgs.set_cancel(true);

                }

    Please let me know if this helps.

Reply Children