Home > Article > Web Front-end > A brief discussion on the scrollBy() method of the window object_javascript skills
Definition and usage of scrollBy() method:
This method can move the content to the specified size. The unit is pixel (px).
Click to see more properties and methods of the window object.
Grammar structure:
scrollBy(x,y)
Parameter list:
Parameter list
x is required. The size to move the content to the right.
y is required. The size by which the content moves downward.
Browser support:
1.IE browser supports this attribute.
2.Firefox browser supports this attribute.
3. Opera browser supports this attribute.
4.Chrome browser supports this attribute.
Code example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>脚本之家</title> <style> *{ margin:0px; padding:0px; } body{ width:1800px; height:1200px; } input{ position:fixed; left:20px; top:20px; } </style> <script type="text/javascript"> function resize(){ window.scrollBy(200,300); } window.onload=function(){ var bt=document.getElementById("bt"); bt.onclick=function(){ resize() } } </script> </head> <body> <input type="button" value="查看效果" id="bt"> </body> </html>
The above is the entire content of this article, I hope you all like it.