我正在使用TouchSwipe来获取html / javascript hybird安卓应用。基本上我想启用触摸/滑动,以便用户可以向左/向右滑动以转到下一页/上一页
<div id="test" class="box">Index</div>
<script>
$(function() {
//Enable swiping...
$("#test").swipe( {
swipe:function(event, direction) {
//direction returns four events: left, right, up & down
//depending on which direction you swiped on the page
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:75
});
});
</script>
我的问题是如何利用这些返回的事件?
例如,如果事件是“左”,我想
window.location.href = "about.html";
否则,如果事件是“正确”,我想
window.location.href = "home.html";
更新:想出来,答案很简单。我让自己太复杂了
if(direction=='left'){
window.location.href = "GuidedTour.xhtml";
}else if(direction=='right'){
window.location.href = "../index.html";
}
答案 0 :(得分:0)
尝试使用jquery来实现效果:
$("#test").swipe(function(event){
window.open($("http://putyourlinkhere.com").attr('href'),'_blank');
},'left');
答案 1 :(得分:0)
更新:想出来,答案很简单。我让自己太复杂了
if(direction=='left'){
window.location.href = "GuidedTour.xhtml";
}else if(direction=='right'){
window.location.href = "../index.html";
}