我正在使用与我的Drupal站点交互的Phonegap开发一个Android应用程序.我已经重新分配Android"后退"按钮以提示用户从Drupal服务器注销,但是我只是想在登录页面上禁用它(原因很明显).我可以让它工作,但只有在用户注销然后在登录页面上,按钮仍然被重新分配为注销按钮.这是我到目前为止的代码:
<head>
<script>
/* Wait until device is ready to re-assign Back button */
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
document.addEventListener("backbutton", onBackKeyPress, false);
}
function onBackKeyPress() {
/* If the current page is the login page, disable the button completely (aka do nothing) */
if ($.mobile.activePage.attr('id') == 'login_page') {
}
/* Else, execute log off code */
else {
if (confirm("Are you sure you want to logout?")) {
/* Here is where my AJAX code for logging off goes */ …
Run Code Online (Sandbox Code Playgroud)