我正在使用此方法更改页面
$.mobile.changePage("Preview.html", {
transition : "slide",
role : "page",
changeHash:true
});
Run Code Online (Sandbox Code Playgroud)
这就是我的预览页面的样子
<div data-role="page" data-name="preview" class="prew">
<div data-role="content">
//content
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在当我触摸屏幕时,我必须回到上一页.
所以我创建了这个功能
$('.prew').live('tap', function() {
alert('clicked');
history.go(-1);//<--this works in simulator not in device.
//window.history.back() ;//<--this also works in simulator not on device.
//navigator.app.backHistory();<--this works fine on android not on iOS.
});
Run Code Online (Sandbox Code Playgroud)
编辑:我使用了一个名为photoswipe的插件导致问题.history.go(-1),history.back()或data-rel ="back"在其他页面上正常工作.
photoswipe无法返回上一页.