help with my JS and HTML box moving mastery (no jquery)
I'm trying to make all objects in a webpage move using js console or bookmarklets. I have a couple of div tags and js. I need CSS for this. why does it say, "Uncaught TypeError: Cannot read property 'length' of undefined Line: 29" here's my JS. var m = document.getElementsByTagName("body"); var l = m.childNodes; var oi; var mi; var mb; var f; function move(){ l[x].style.position = "relative"; if (l[x].style.top>(window.innerHeight/2)-l[x].height){ oi = l[x].style.top; l[x].style.top=oi+1; }else if(l[x].style.top<(window.innerHeight/2)+l[x].height){ oi = l[x].style.top; l[x].style.top=oi-1; }else{ mb = 1; }if (l[x].style.left>(window.innerWidth/2)-l[x].width){ oi = l[x].style.left; l[x].style.left=oi+1; }else if(l[x].style.left<(window.innerWidth/2)+l[x].width){ oi = l[x].style.left; l[x].style.left=oi-1; }else{ mi = 1; }if((mb==1)&&(mi==1)){ x++; } } for(var x=0;x<l.length;){ f = setInterval(move,100); } here's HTML. <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <div style = "background:rgb(0,0,0); width:200;height:20;"> </div> <div style = "background:rgb(255,0,0); width:200;height:20;"> </div> <div style = "background:rgb(255,0,0); width:200;height:20;position:relative;top:400;"> </div> <div style = "background:rgb(255,0,0); width:200;height:20;position:relative;left:300;"> </div> </body> </html> send me a code or fixed version of the js if you figure it out.