scrollBy()方法的定義和用法:
此方法可以把內容移動指定尺寸。單位是像素(px)。
點擊可參閱更多window對象的屬性和方法。
語法結構:
scrollBy(x,y)
參數列表:
參數 列表
x 必需。內容向右移動的尺寸。
y 必需。內容向下移動的尺寸。
瀏覽器支持:
1.IE瀏覽器支持此屬性。
2.Firefox瀏覽器支持此屬性。
3.Opera瀏覽器支持此屬性。
4.chrome瀏覽器支持此屬性。
代碼實例:
<!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>
以上所述就是本文的全部內容了,希望大家能夠喜歡。
新聞熱點
疑難解答