+2 votes
295 views
in Programming by (670 points)
I want a button on web page in which when user click on that button window should scroll down, How can we do it with simple java script?

Thanks For Answering !
closed

1 Answer

+2 votes
by Expert (5.1k points)
selected by
 
Best answer
<!DOCTYPE html>
<html>
<body>
 
<p>it might be helpful for you!.</p>
 
 
<button onclick="scrollWin(0,100)" style="position:fixed;">Scroll down</button><br><br>
 
 
<div style="border:1px solid black;background-color:lightblue;height:7500px;width:5000px;">
</div>
 
<script>
function scrollWin(x,y)
{
window.scrollBy(x,y);
}
</script>
 
</body>
</html>
 
by (670 points)
Wow Thanks amit_pammu its working ...Could you explain the code here how its happening actually i am new in programming.
by Expert (5.1k points)
basically , its just a javascript predefined window property,,scrollBy...
and you have to just give the dimensions .
like..the above code!!!.

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated