首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >接收到事件时加载另一个.html页面

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

Stack Overflow用户
提问于 2015-03-08 16:13:21
回答 2查看 815关注 0票数 0

我用TouchSwipe制作了一个html/javascript hybird android应用程序。基本上,我希望启用触摸/滑动,这样用户就可以向左/右滑动到下一页/上一页。

代码语言:javascript
复制
<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>

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

例如,如果事件是“左”的,我想

代码语言:javascript
复制
window.location.href = "about.html";

否则,如果事件是“正确的”,我想

代码语言:javascript
复制
window.location.href = "home.html";

更新:找出了答案,答案很简单。我把自己弄得太复杂了

代码语言:javascript
复制
if(direction=='left'){
        window.location.href = "GuidedTour.xhtml";
      }else if(direction=='right'){
        window.location.href = "../index.html";
      }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-11 17:42:18

更新:搞清楚了,答案很简单。我把自己弄得太复杂了

代码语言:javascript
复制
if(direction=='left'){
    window.location.href = "GuidedTour.xhtml";
  }else if(direction=='right'){
    window.location.href = "../index.html";
  }
票数 0
EN

Stack Overflow用户

发布于 2015-03-08 16:22:04

尝试使用jquery实现以下效果:

代码语言:javascript
复制
$("#test").swipe(function(event){
    window.open($("http://putyourlinkhere.com").attr('href'),'_blank');
},'left');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28928716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档