本文实例讲述了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程序设计有所帮助。