Webmaster

Scripts

A scrolling background

Web pages showing a static background are commonplace. Use the following JavaScript to animate any background image!

First, define the background image in the usual way:

<body background="background_image.gif">

Then insert this script, unmodified, into your page right after the <Body> tag:

<script language="JavaScript">
<!-- Begin
var backgroundOffset = 0;
var bgObject = eval('document.body');
function scrollBG(maxSize) {
backgroundOffset = backgroundOffset + 1;
if (backgroundOffset > maxSize) backgroundOffset = 0;
bgObject.style.backgroundPosition = "0 " + backgroundOffset;
}
var ScrollTimer = window.setInterval("scrollBG(307)", 64);
// End -->
</script>

It's that simple and the result is guaranteed!

Discover all Webmaster scripts.