在mousescroll上滚动100%

时间:2016-05-18 20:09:20

标签: javascript jquery html css

我希望在用户开始滚动时执行操作。我尝试研究网络,但唯一出现的是100%滚动点击:)

一旦用户开始在鼠标滚轮上滚动,我希望窗口被强制100%降低。这可能吗? :)谢谢。

5 个答案:

答案 0 :(得分:1)

首先: 强制屏幕一直向下滚动的问题在于您无法再在屏幕上移动 - 因为每次滚动时都会重置位置。

但是,您可以使用JQuery并收听scroll事件。

这样的事情:

$(document).on('scroll', function(){
    console.log('yeah');
    // window.scrollTo(0,document.body.scrollHeight); // left this commented out
});

你也可以在没有JQuery的情况下做同样的事情。只是简单的旧JavaScript

document.onscroll = function(){ 
                      console.log('oh yeah');
                      // window.scrollTo(0,document.body.scrollHeight); // left this commented out
                    }

答案 1 :(得分:0)

您可以查看jQuery Mousewheel插件:http://plugins.jquery.com/mousewheel/

答案 2 :(得分:0)

是的,实际上非常简单,做了类似的事情:

$(window).bind("wheel", function (e) { if (e.deltaY > 0) // please just check if you should compare > 0 or < 0, i don't have a mouse here :) to check the event $("body").scrollTop(10e9); });

答案 3 :(得分:0)

让我知道这是否真的是你想要的,因为这在技术上会检查页面中的任何滚动,特别是鼠标滚轮,希望jQuery没问题。

$( document ).ready(function() {
    $(window).scroll(function (event) {//Checks if scroll happens
        //set the left offset to 0, set the second one to the height of the document
        window.scroll(0,document.body.scrollHeight);
    });
});

同样,这适用于任何滚动动作。

答案 4 :(得分:0)

1)添加一些不可见的链接:

<a id="jump-on-scroll" href="#bottom" style="color:white">...</a>

2)在鼠标滚轮上:

$(window).bind("wheel", function (e) {
   if (e.deltaY > 0) {
     $('#jump-on-scroll').trigger('click');
   }
});