我需要通过滚动鼠标将当前页面更改为另一个页面。
想象一下,Wordpress 上用于更改另一个帖子的正常功能……prev_post 和 next_post。当您在模板中使用它时,您将获得两个链接。一个是上一篇,第二个是下一篇。当您单击其中一个时,您将被移动到下一页或上一页。我需要通过滚动鼠标滚轮来做同样的事情。
有人可以知道该怎么做吗?
我会说这样的话:
$(window).bind("mousewheel DOMMouseScroll", function(e){
var delta = parseInt(e.originalEvent.wheelDelta || -e.originalEvent.detail);
if(delta > 0) {
window.location.href = nextpage;
} else {
window.location.href = previouspage;
}
});
虽然这可能很烦人,但这只是我的意见。
var url = document.URL, // full page URL
pages = [ "index.html", "about.html", "contact.html" ], // LIST OF PAGES
// retrieve pagename and it it's "" means we're on index.html
currPage = url.substring(url.lastIndexOf('/') + 1) || "index.html",
wheelAt = $.inArray(currPage, pages), // get 0,1,2,3
您也可以使用Brandon Aaron jQuery mouseWheel 插件。
wheelAt =
mousewheel up||down (-1, +1)window.location = pages[ wheelAt ]