Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> JavaScript >> Snippet

Move an image across the screen


< div id = "x" style = "position:absolute; top:0; left:-20;" >< img src = "dot.gif" width = "10" height = "10" ></ div >

< script ><!--
function moveit() {
    if (document.all) {
       document.all.x.style.posLeft = document.all.x.style.posLeft + 20;
        if (document.all.x.style.posLeft < screen.width)
           setTimeout( "moveit()" ,100);
    }
    else if (document.layers) {
       document.x.left += 20;
        if (document.x.left < screen.width)
           setTimeout( "moveit()" ,100);
    }
}

if (document.all || document.layers)
   moveit();
//--></script>