0

I am using the following code:-

 .directive('confirmOnExitForm', function() {
        return {
            link: function($scope, elem, attrs) {
                window.onbeforeunload = function(){
                    if ($scope.form.$dirty) {
                        return "The form is dirty, do you want to stay on the page?";
                    }
                }

            }
        };
    })

This code is working fine on Desktops Chrome and Safari, but it is not working for Android and Iphones.

Any idea why?

Raef Kandil
  • 307
  • 1
  • 12
  • please refer this link https://stackoverflow.com/questions/4127621/is-there-any-way-to-use-window-onbeforeunload-on-mobile-safari-for-ios-devices – Jalpa Nov 10 '17 at 05:00
  • https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5 – Jalpa Nov 10 '17 at 05:02
  • https://stackoverflow.com/questions/3239834/window-onbeforeunload-not-working-on-the-ipad?noredirect=1&lq=1 – Jalpa Nov 10 '17 at 05:26
  • Please try above solutions and let me know. – Jalpa Nov 10 '17 at 05:27
  • Does this answer your question? [window.onbeforeunload not working on the iPad?](https://stackoverflow.com/questions/3239834/window-onbeforeunload-not-working-on-the-ipad) – miken32 Dec 21 '19 at 01:34

0 Answers0