Purchase Advertising On AWT
 Upload & Sell Your Software
 Upload & Sell Your eBook
 Enter The AWT Control Panel  Contact Applied Web Tools
 Sell Your eBook @ The Book Store  Password Troubles? Click Here!
Knowledge Center
Want to write for Applied Web Tools? Send your Writer's Query to
Editor@AppliedWebTools.net for details.
HTML
Reference
&
Tutorial
CSS
Reference
&
Tutorial
DOM
Reference
&
Tutorial
JavaScript
Reference
&
Tutorial
50+ Programming Examples
Use HTML, CSS, DOM & JavaScript Together
Misc. Essays & Documents
You'll Find Just About Anything In Here
50+ Web Page Constructions
Learn the Art of Using HTML, CSS, DOM & JavaScript Together
 Changing Background Colors
 Event Triggering With onLoad
 Disabling The Right Click
 DOM Driven Color Changing
 Switching Images
 innerHTML Attribute Access
 Change With innerHTML
 Changing Positions
 Change Position With onMouseMove
 Change Text Position
 Interactivity Skills
 Type-writing A Message
 Auto-changing Text Size
 Making Text Scroll
 Blinking Text
 Simple Form Authentication
 Change Background Color Of An INPUT
 Change Text Color Of An INPUT
 Change Background Image Of An INPUT
 Select All Checkboxes
 Select Color Of The Submit Button
 Change Text Color Of A Submit Button
 Insert Background Image To A Button
 Change Color Of Drop Down List
 Change Text Color Of A Drop Down List
 Change Color Of A TEXTAREA
 Change The Text Color Of A TEXTAREA
 Insert An Image Into A TEXTAREA
 Change The Size Of An Image
 Change The Source Of An Image
 Change The Position Of An Image
 Change The Background Image
 Moving Images Around The Page
 Drag & Drop An Image
 A Simple Image Viewer
 A Shaking Image
 A Digital Clock
 Drop Down List Link
 Top Drop Down Menu
 Always On Top Menu
 Inset Border Buttons
 A Description Generating Menu
 An Image Generating Menu
 A Horizontal Sliding Menu
 A Click Horizontal Sliding Menu
 Returning Cursor Co-ordinates
 Making Text Follow The Cursor
 Attaching An Image To The Cursor
moving an image

So we’ve all seen those moving banners on web pages now and then. The way this is accomplished is much easier than you might think. We use a relative positioned item and simply add a new position to it, in increments or one in this case through the use of the increment operator (++).

We start by assigning an initial value to the position, in this case 1. We then increment that value a set number of times every 10 milliseconds. To make the image travel faster, increase the amount incremented or reduce the amount of milliseconds to make each position change, or a combination of both.

<html>
<head>

<script type="text/javascript">
var i=1
function starttimer() {
document.getElementById('myimage').style.position="relative";
document.getElementById('myimage').style.left=+i;
i++;
timer=setTimeout("starttimer()",10);
}

function stoptimer() {
clearTimeout(timer);
}
</script>

</head>

<body onload="starttimer()" onunload="stoptimer()">
<img id="myimage" src="smiley.gif" width="32" height="32" />
</body>
</html>


Start with the original position of the image stated normally. As the image position is always available to be read, so it is to be altered. If you’re getting a jumpy, dithered sort of effect, alter the time of each positioning to a smaller value. This will give you a finer degree of control.

If you’d like to explore this further, think about changing the image or resizing the image with each position change. There can be more than one DOM statement applied to a page element within a JavaScript function, so there are quite a few more options to be figured out.
I do not employ cookies or tracking devices of any kind