Javascript 收到事件时加载另一个.html页面
我正在使用一个html/javascript混合android应用程序。基本上,我想启用触摸/滑动,以便用户可以向左/向右滑动以转到下一页/上一页Javascript 收到事件时加载另一个.html页面,javascript,android,jquery,html,touchswipe,Javascript,Android,Jquery,Html,Touchswipe,我正在使用一个html/javascript混合android应用程序。基本上,我想启用触摸/滑动,以便用户可以向左/向右滑动以转到下一页/上一页 <div id="test" class="box">Index</div> <script> $(function() { //Enable swiping... $("#test").swipe( {
<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";
}
if(direction=='left'){
window.location.href = "GuidedTour.xhtml";
}else if(direction=='right'){
window.location.href = "../index.html";
}
尝试使用jquery来实现以下效果:
$("#test").swipe(function(event){
window.open($("http://putyourlinkhere.com").attr('href'),'_blank');
},'left');
更新:弄明白了,答案很简单。我把自己弄得太复杂了
if(direction=='left'){
window.location.href = "GuidedTour.xhtml";
}else if(direction=='right'){
window.location.href = "../index.html";
}
if(direction=='left'){
window.location.href = "GuidedTour.xhtml";
}else if(direction=='right'){
window.location.href = "../index.html";
}