HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> body{ width:3000px; height:3000px; } p{ margin-top:200px; } </style> </head> <body> <p>Scroll the vertical scroll bar towards bottom or top at different position and click 'scrollY' button.</p> <button onclick="myFunction()">scrollY</button> <script> window.scrollBy({ top: 100, left: 0, behavior: "auto" }); function myFunction(){ alert("Scroll Top: "+window.scrollY); } </script> </body> </html>
OUTPUT
×

Save as Private