| | |
Got a funny bit of javascript
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hey, my friend sent me this funny java script, if you copy and paste it in the adress bar and hit enter it makes the links spin around, any one know how this works?
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=2.6; y3=.24; x4=100; y4=100; x5=300; y5=300; 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);
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=2.6; y3=.24; x4=100; y4=100; x5=300; y5=300; 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);
Well it declares some variables R=0; x1= blah y1=blah...
Then where it starts 'DI' that's an array of images on the page (DI probably for DocumentImages) document.getElementsByTagName("img") returns an array of references to every img object in the DOM (Document Object Model). DIL is the length of DI so that's the count of the images found in the page, A function is then created that loops through the image list, gets the style attribute of each one and changes its css positioning in the dom. Finally function A is called using the built in javascript function setInterval which continuously runs function A every 5 (I think milliseconds i'm not sure of the units without looking it up)
Then where it starts 'DI' that's an array of images on the page (DI probably for DocumentImages) document.getElementsByTagName("img") returns an array of references to every img object in the DOM (Document Object Model). DIL is the length of DI so that's the count of the images found in the page, A function is then created that loops through the image list, gets the style attribute of each one and changes its css positioning in the dom. Finally function A is called using the built in javascript function setInterval which continuously runs function A every 5 (I think milliseconds i'm not sure of the units without looking it up)
•
•
Join Date: Jan 2009
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
Hey, my friend sent me this funny java script, if you copy and paste it in the adress bar and hit enter it makes the links spin around, any one know how this works?
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=2.6; y3=.24; x4=100; y4=100; x5=300; y5=300; 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);
![]() |
Similar Threads
- Alert box, then cancel action (Javascript) (JavaScript / DHTML / AJAX)
- php loading (PHP)
- Bottom of Firefox/IE (HTML and CSS)
- HELP! With Javascripts Pop-Up Window (JavaScript / DHTML / AJAX)
- Safe Menu's ? (HTML and CSS)
- Arizona Web wants reviews too! (Website Reviews)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: prototype successive ajax.updater requests fail on Windows only
- Next Thread: javascript in ajax part of site doesn't work
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxhelp animate array automatically beta box bug calendar cart checkbox child class codes column cookies createrange() css cursor date debugger decimal design dom download dropdown editor element enter error explorer file firefox focus forms frameworks getselection google gwt html htmlform ie8 iframe images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jsp jump listbox maps masterpage math menu microsoft mimic mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent php player post problem programming progressbar prototype redirect regex runtime safari scale scriptlets search select session shopping size sql text textarea toggle variables w3c web website window windowofwords windowsxp wysiwyg \n






