1
我希望能够在一个JavaScript函数(android/HTML5项目)中回退到上一页。我可以通过history.back()
回到上一页,但是,这段代码不会回退。以编程方式返回上一页
是否有可能使其滑动以及?
我希望能够在一个JavaScript函数(android/HTML5项目)中回退到上一页。我可以通过history.back()
回到上一页,但是,这段代码不会回退。以编程方式返回上一页
是否有可能使其滑动以及?
这里有一个工作示例:http://jsfiddle.net/Gajotres/ru3D3/
$(document).off('swipeleft').on('swipeleft', 'article', function(event){
var nextpage = $.mobile.activePage.next('article[data-role="page"]');
// swipe using id of next page if exists
if (nextpage.length > 0) {
$.mobile.changePage(nextpage, {transition: "slide", reverse: false}, true, true);
}
});
$(document).off('swiperight').on('swiperight', 'article', function(event){
history.back();
return false;
event.handled = true;
});
这段代码是用来返回到上一个页面:
history.back();
return false;
在这一行:
$(document).off('swiperight').on('swiperight'
.off(..)用于在页面转换期间防止多个滑动事件绑定。如果你有更多的问题,请不要犹豫。
工作示例也在这里:http://jsfiddle.net/Gajotres/ru3D3/
$(document).on('pagebeforeshow', '[ data-role="page"]', function(){
$(document).off('click touchStart').on('click touchStart', '#slide-back-btn', function(){
history.back();
return false;
});
});
设置'$ .mobile.changePage( “../ MYPAGE#myTag”,{过渡: '滑',反向:真});'做了诡计 – Daniel