jQuery Mobile get current page

后端 未结 8 1325
孤城傲影
孤城傲影 2021-02-04 01:44

I am using jQuery Mobile 1.1.1 and Apache Cordova 2.0.0. I want my app to exit when I press back button but only if current page have ID = feedZive. I am using following code to

8条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 02:35

    $(document).ready(function() {
    
    //exit when back button pressed on home screen
    document.addEventListener("deviceready", function() {
        document.addEventListener("backbutton", function() {
            if ($.mobile.activePage.attr('id') == "home") {
                navigator.app.exitApp();
            } else {
                navigator.app.backHistory();
            }
        }, false);
    }, false);
    

    });

提交回复
热议问题