내 PhoneGap android 앱에서 내 Index.html 페이지의 OnDeviceReady() 메서드에 backbutton 이벤트 리스너에 대해 다음 함수를 추가했습니다. 직면BackButton 이벤트가 PhoneGap의 다른 페이지에 영향을 미침
document.addEventListener("backbutton", function(e) {
var sPath=window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if(sPage == "index.html"){
e.preventDefault();
// My action
return false;
} else {
return true;
}
}, false);
문제 : 내 홈페이지 (Index.html 것)의 작업 벌금
. 다시 버튼을 누르면 닫힙니다.
그러나 다른 모든 페이지 (Page1.html, Page2.html, Page3.html, Page4.html) 나는 backbutton 이벤트 수신기를 만들지 않았지만 아무 키도 누르지 않으면 아무 일도 발생하지 않습니다. 다음과 같은 자바 스크립트 코드를 추가하여 시도 할 수 있습니다
는 어떻게 다른 페이지로 홈페이지에서 이동? –
"window.location ="page1.html "; 코드를 사용하여 버튼 클릭 이벤트에서" – Vignesh