首页 文章

退出按钮按Windows操作使用javascript

提问于
浏览
2

我使用Windows移动应用程序(phonegap)的以下功能来处理后退导航功能 .

function onBackKeyDown() {

    var currentPageId = $.mobile.activePage.attr('id');

    if(currentPageId == 'contact-us' || currentPageId == 'about-us' || currentPageId == 'location-map' || currentPageId == 'services'){

    $.mobile.changePage("index.html", {
    transition : "slide",
    reverse : true,
    changeHash : false
    });

    }else{
    navigator.app.exitApp();

    }

}

如果当前页面不是索引,我想来索引 . 否则退出应用程序 . 似乎navigator.app.exitApp()在Windows Phone 7中不起作用 . 有没有解决此问题的解决方案 .

1 回答

  • 1

    这个插件对我来说很方便 .

    http://shinymetilda.github.io/Cordova_Exit_Plugin/

    将.cs文件添加到插件目录中 .

    将以下代码添加到config.xml

    <feature name="AppTerminate">
           <param name="wp-package" value="AppTerminate" />
        </feature>
    

    编写此代码而不是navigator.app.exitApp()

    cordova.exec(null, null, "AppTerminate", "execute", []);
    

相关问题