Scroll a window in Javascript in JavaScript

Description

The following code shows how to scroll a window in Javascript.

Example


<!--  www. j  av  a2 s.  c om-->
<!DOCTYPE HTML>
<html>
<body>
<p>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>
This is a test. <br/>

</p>
<script>
window.scrollTo(0, 400);
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Scroll a window in Javascript in JavaScript