Jump to content

How does this script work(browser entry)


slomz

Recommended Posts

I have this code a friend made, and it is javascript, but I don't see any commands that I saw when going through the tutorial.

java script:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0)

Link to comment
Share on other sites

try laying the script out more simple:

java script:R=0;x1=.1;y1=.05;x2=.25;y2=.24;x3=1.6;y3=.24;x4=300;y4=200;x5=300;y5=200;DI=document.getElementsByTagName("img");DIL=DI.length;function A() { for(i=0; i-DIL; i++){  DIS=DI[ i ].style;  DIS.position='absolute';  DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px";  DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"; } R++}setInterval('A()',5); void(0);

it uses HTML DOM .. so that's probably why you don't see many of the commands you learnt.i'm guessing with it starting with "java script:" it's being stored in the element (eg. ....onclick="java script:R=0.....") so you will have to keep it as you have it now.

Link to comment
Share on other sites

it uses HTML DOM .. so that's probably why you don't see many of the commands you learnt.
Yeah, most of the time when you are using javascript to do various things with a webpage, you are actually using the HTML DOM. I'd guess that about 70% of client-side scripting (if not more) is HTML DOM rather than javascript. Go through the tutorial here: http://www.w3schools.com/htmldom/default.asp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...