AngularJS window.onbeforeunload is not working on Android and Iphone

心已入冬 提交于 2019-12-11 15:29:12

问题


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?

来源:https://stackoverflow.com/questions/47150350/angularjs-window-onbeforeunload-is-not-working-on-android-and-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!