2013-08-15 3 views
2

Windows Mobile 앱 (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

이 플러그인은 나에게 도움이되었습니다.

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

는 .cs이 플러그인 디렉토리에 파일을 추가합니다.

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

쓰기 대신 navigator.app.exitApp (이 코드)

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

나 감사를 위해 일을 config.xml에 다음 코드를 추가 – Harsh