本文實例講述了JS實作讓網頁背景圖片斜向移動的方法。分享給大家供大家參考。具體實作方法如下: 複製程式碼 程式碼如下: JS實作讓網頁背景圖片斜向移動 <br /> <!--<br /> function selectAll(theField){<br /> var tempval=eval("document." theField)<br /> tempval.focus()<br /> tempval.select()<br /> }<br /> //--><br /> <br /> <!--<br /> var background = "images/changshi.ico";<br /> var speed = 0;<br /> browserName = navigator.appName;<br /> browserVer = parseInt(navigator.appVersion);<br /> if (browserName != "Netscape" || browserVer >= 4.5) {<br /> function moveback(movert,movedn,hPos,vPos) {<br /> if (arguments[4])<br /> document.body.style.backgroundImage = "url("" arguments[4] "")";<br /> if (arguments[5])<br /> document.body.style.backgroundRepeat = arguments[5]<br /> if (!isNaN(hPos)) {<br /> if ((movert!=0) && (hPos>0)) hPos=-100000<br /> hPos = movert<br /> } <br /> if (!isNaN(vPos)) {<br /> if ((movedn!=0) && (vPos>0)) vPos=-100000<br /> vPos = movedn<br /> }<br /> document.body.style.backgroundPosition= hPos " " vPos<br /> if (isNaN(hPos)) hPos = """ hPos """<br /> if (isNaN(vPos)) vPos = """ vPos """<br /> setTimeout("moveback(" movert "," movedn "," hPos "," vPos ")",speed)<br /> }<br /> moveback(1,1,0,0, background);<br /> } <p>//--><br /> 希望本文所述對大家的javascript程式設計有所幫助。