This article describes the method of JS to move the background image in the web page in a diagonal manner. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows: <html>
<head>
<title>JS implements the web background image to move obliquely</title>
<body background="images/changshi.ico">
<script language="Javascript">
<!--
function selectAll(theField){
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
}
//-->
</script>
<script language="Javascript">
<!--
var background = "images/changshi.ico";
var speed = 0;
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if (browserName != "Netscape" || browserVer >= 4.5) {
function moveback(movedn,hPos,vPos) {
if (arguments[4])
document.body.style.backgroundImage = "url(/"" + arguments[4] + "/")";
if (arguments[5])
document.body.style.backgroundRepeat = arguments[5]
if (!isNaN(hPos)) {
if ((movert!=0) && (hPos>0)) hPos=-100000
hPos += move
}
if (!isNaN(vPos)) {
if ((movedn!=0) && (vPos>0)) vPos=-100000
vPos+= movedn
}
document.body.style.backgroundPosition= hPos + " " + vPos
if (isNaN(hPos)) hPos = "/"" + hPos + "/""
if (isNaN(vPos)) vPos = "/"" + vPos + "/""
setTimeout("moveback("+movvert+","+movedn+","+hPos+","+vPos+")",speed)
}
moveback(1,1,0,0, background);
}
//-->
</script>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.