控制硬件后退按钮jQuery Mobile [英] Take control of hardware back button jquery mobile

查看:108
本文介绍了控制硬件后退按钮jQuery Mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了以下链接,我的处境也一样.

I have gone through the following link and my situation is same like it.

禁用硬件后退功能jquery mobile

情况:被测设备:三星S3

Situation: Device under test : Samsung S3

页面A:具有名称(A1,A2,A3)的ListView 网页B:由表单",提交"和取消"按钮组成.

Page A: ListView with Names(A1, A2, A3) Page B: Consist of Form, Submit and Cancel button.

用户填写表格,然后单击提交"按钮.并且他的数据被上传到服务器.页面已更新,并显示确认对话框,表明数据已上载到服务器.

User fills the form and click on submit button. And his data gets uploaded to server. Page is updated and Confirmation dialog is displayed that data is uploaded to server.

现在问题出现了.

现在,当用户单击硬件后退"按钮时,他再次被重定向到页面B,并且再次能够提交表单(我们不需要,因为该表单仅可以填写一次).

Now when the user clicks on Hardware back button he is again redirected to Page B and he is again able to submit the form (which we don't require, as the form is meant to be filled only once).

那么我有什么方法可以控制硬件后退按钮在页面B上显示页面A.

So is there any way through which I can control the hardware back button to show Page A whenever it is on Page B.

以下Nirmal的答案似乎有答案,但我不知道如何实现-

The following answer from Nirmal seems to have answer but I don't know how to implement it-

没有真正的方法来禁用硬件上的后退按钮 Blackberry或Android.

There is no real way disable the hardware back button on the Blackberry or Android.

您可以做的是维护一个会话变量,该变量将变得无效 在您的后台处理程序中,并在 考试页面的pagebeforeshow事件.

What you can do is maintain a session variable which gets invalidated in your back handler and check for that session variable in the pagebeforeshow event of the Exam page.

有人可以帮助我吗?

推荐答案

您应该能够使用javascript捕获硬件后退按钮单击事件.

You should be able to capture hardware back button click event with javascript.

$(document).bind('keydown', function(event) {
  if (event.keyCode == 27) {
    // Prevent default (disable the back button behavior)
    event.preventDefault();

    // Your code to show another page or whatever...
  }
});

这篇关于控制硬件后退按钮jQuery Mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆