This article describes the method of JS to continuously move web page background. Share it for your reference. The specific implementation method is as follows:
Copy the code as follows: <html>
<head>
<title>JS implementation of continuous flowing web page background</title>
</head>
<body background="/images/bg002.jpg">
<script language="JavaScript">
<!-- Begin
var backgroundOffset = 0; //Offset of background image
var bgObject = eval('document.body'); //Get the object of the document itself
function scrollBG(maxSize) { //This function is the core of the scroll background
backgroundOffset = backgroundOffset + 1; //Add 1 point to the background offset
if (backgroundOffset > maxSize) backgroundOffset = 0; //If the offset exceeds the maximum value, it will return to zero
bgObject.style.backgroundPosition = "0 " + backgroundOffset; //Set the offset of the background to make it take effect
}
var ScrollTimer = window.setInterval("scrollBG(307)", 64); //Set the interval between each movement of the background.
// End -->
</script>
<div style="position: absolute; top: 200; left:300;">
<table cellpacing="0" cellpadding="0">
<tr>
<td><b>Is the flowing background very beautiful? </b></td>
</tr>
</table>
</div>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.