我用TouchSwipe制作了一个html/javascript hybird android应用程序。基本上,我希望启用触摸/滑动,这样用户就可以向左/右滑动到下一页/上一页。
<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";
}发布于 2015-03-11 17:42:18
更新:搞清楚了,答案很简单。我把自己弄得太复杂了
if(direction=='left'){
window.location.href = "GuidedTour.xhtml";
}else if(direction=='right'){
window.location.href = "../index.html";
}发布于 2015-03-08 16:22:04
尝试使用jquery实现以下效果:
$("#test").swipe(function(event){
window.open($("http://putyourlinkhere.com").attr('href'),'_blank');
},'left');https://stackoverflow.com/questions/28928716
复制相似问题