为了处理滑动,我使用了在这里发布的脚本:http://padilicious.com/code/touchevents/
效果很好。
现在,我不想更改背景(原始脚本所做的),而是希望它获取包含在<a>中的链接,该链接具有类,通常是指向下一页的链接,但对于鼠标事件,如:
<a href="mypage02.html" target="_self" class="NextP" title="My Second Page">然后加载页面。
我有很多页面,具有相同的结构,我不想手动定义链接。我希望js能够获得包含在<a>中的当前<a>,并在被滑动触发时启动它。如果可能的话。
谢谢-)
发布于 2015-03-26 20:51:11
据我所知,你想找一个
<a href="http://example.com/" class="NextP">元素(带有<a>类的NextP锚标记),当用户滑动时,访问该链接。
为了做到这一点,我会
a.NextP元素,并捕获其href属性。window.location.href设置为此属性。window.onload = function(){
var nextPageUrl = document.querySelectorAll('a.NextP')[0].href;
// just guessing how swiping works, I haven't looked through your library
document.body.onswiperight = function(){
window.location.href = nextPageUrl;
};
};当然,你会使用正确的方法来检测刷卡。
https://stackoverflow.com/questions/29288237
复制相似问题