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

2012-02-23 16:56:57 +08:00
 Eyon
<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

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

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

@benzhe 正解
Eyon
2012-02-23 17:32:30 +08:00
@benzhe 谢谢、搞定、记笔记..

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/27993

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX