V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Eyon
V2EX  ›  问与答

如何让这段 JS 能够在 iPad 上正常运行

  •  
  •   Eyon · 2012-02-23 16:56:57 +08:00 · 4127 次点击
    这是一个创建于 4437 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
    <script src="http://tab-slide-out.googlecode.com/files/jquery.tabSlideOut.v1.3.js"></script>

    <script type="text/javascript">
    $(function(){
    $('.slide-out-div').tabSlideOut({
    tabHandle: '.handle', //class of the element that will become your tab
    pathToTabImage: 'images/contact_tab.gif', //path to the image for the tab //Optionally can be set using css
    imageHeight: '122px', //height of tab image //Optionally can be set using css
    imageWidth: '40px', //width of tab image //Optionally can be set using css
    tabLocation: 'left', //side of screen where tab lives, top, right, bottom, or left
    speed: 300, //speed of animation
    action: 'hover', //options: 'click' or 'hover', action to trigger animation
    topPos: '200px', //position from the top/ use if tabLocation is left or right
    leftPos: '20px', //position from left/ use if tabLocation is bottom or top
    fixedPosition: false //options: true makes it stick(fixed position) on scroll
    });

    });

    </script>




    这段代码中的 action:hover 在 iPad 中虽然也能点击,但点一下又缩回去了......

    其实,就是解决http://t.cn/zOy9y5T这个页面在 iPad 上浏览时,左侧导航点一下就缩回去的问题.......

    代码来自 http://www.building58.com/examples/tabSlideOut.html

    请高人帮忙
    6 条回复    1970-01-01 08:00:00 +08:00
    cutehalo
        1
    cutehalo  
       2012-02-23 17:00:13 +08:00
    action: 'hover', //options: 'click' or 'hover', action to trigger animation
    把这里的hover改成click?其实我是猜的 没仔细看....
    cutehalo
        2
    cutehalo  
       2012-02-23 17:01:45 +08:00
    好像还真是这样....iPad上面没有鼠标 没法hover 改成click就变成点击显示了
    Eyon
        3
    Eyon  
    OP
       2012-02-23 17:01:54 +08:00
    @cutehalo 呃,但是在 Desktop 上我需要 hover......在 iPad 上就需要 变成 click
    benzhe
        4
    benzhe  
       2012-02-23 17:16:58 +08:00
    ...
    action:navigator.userAgent.indexOf('iPad')>=0?'click':'hover',
    ...

    这样应该可以吧
    cutehalo
        5
    cutehalo  
       2012-02-23 17:23:58 +08:00
    @Eyon 这样- -

    @benzhe 正解
    Eyon
        6
    Eyon  
    OP
       2012-02-23 17:32:30 +08:00
    @benzhe 谢谢、搞定、记笔记..
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3649 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 04:52 · PVG 12:52 · LAX 21:52 · JFK 00:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.