如何在Jquery mobile中控制后退按钮事件?
我试图控制后退按钮,但我不能。在这里;
控制硬件后退按钮jquery mobile
event.keyCode == 27 //thats for escape event.keyCode == 8 //thats for backspace..its also working on browser but it doesnt work on my tablet.
有什么建议??
推荐方法
pagecontainerbeforechange
: https : //jqmtricks.wordpress.com/2014/12/01/detect-back-navigation/
您需要侦听navigation
事件和state.direction
。
$(window).on("navigate", function (event, data) { var direction = data.state.direction; if (direction == 'back') { // do something } if (direction == 'forward') { // do something else } });
jQM API: 导航事件
演示