收到事件时加载另一个 .html 页面

Load another .html page when an event is recieved

我正在使用 TouchSwipe 作为 html/javascript hybird android 应用程序。基本上我想启用 touch/swipe 以便用户可以滑动 left/right 转到 next/previous 页面

<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>

我的问题是如何利用这些返回的事件?

例如,如果事件是 "left" 我想

window.location.href = "about.html";

否则如果事件是 "right" 我想

window.location.href = "home.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";
  }