Page Redirect when giving Scroll

Asked

Viewed 80 times

0

Good afternoon, I’m in need of some code that allows Immediate Redirect to another page when giving Scroll (no matter how little Scroll is done, even the smallest movement). Someone can give me a tip, I’m still half beginner. Thank you all!

2 answers

0

For me this is not a good practice because scroll bars are side areas to the browser window, which signal the existence of content that goes beyond the visible area of the page and allow the scrolling of the window to reach it, helping to adapt the window to the published content.

JQUERY

To be as fast as possible it is best to make it right on the click because who goes to the Scroll the intention is always to roll!

var clickedOnScrollbar = function(mouseX){
  if( $(window).outerWidth() <= mouseX ){
    return true;
  }
}

$(document).mousedown(function(e){
  if( clickedOnScrollbar(e.clientX) ){
    window.location = "/";
  }
});
#a {
height:1200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="a"></div>

0

You can do this simply with Javascript:

<script>
window.onscroll = function(){  
   location.href = "outra_pagina.html";
}
</script>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.