Exempel;
<div id="foo" style="position:absolute;left:-50px;top:100px;">En_bild</div>
<script type="text/javascript" language="JavaScript">
xpos=-50; ypos=100; speed=10; delay=50;
function runMeMany(){
xpos+=speed;
moveLayerAbs('foo',xpos,ypos);
(xpos<getClientWidth())?setTimeout('runMeMany()',delay):hideLayer('foo');
}
function moveLayerAbs(Id,x,y){
if (document.all){
if (x) document.all[Id].style.left = x;
if (y) document.all[Id].style.top = y;
} else if (document.layers){
if (x) document.layers[Id].left = x;
if (y) document.layers[Id].top = y;
} else if (document.getElementById){
if (x) document.getElementById(Id).style.left = x+'px';
if (y) document.getElementById(Id).style.top = y+'px';
}
}
function hideLayer(Id){
if (document.all) {
document.all[Id].style.visibility = "hidden";
} else if (document.layers){
document.layers[Id].visibility = "hide";
} else if (document.getElementById){
document.getElementById(Id).style.visibility = "hidden";
}
}
function getClientWidth(){
return (document.all)?document.body.clientWidth:window.innerWidth;
}
</script>
startas enklast från <body> med onload="runMeMany()"