Javascript: Flying Pictures Effect

Copy and paste the code below in address line ofВ page with picturesВ and see the pictures flying effect. No harm, tested with Internet Explorer 6.0, 7.0, В Opera 8.54В and Firefox 1.5 (0.6, 0.7).

IMPORTANT: after you pasted it into the browser address line, replace all quotes with single quotes (because of UTF-8 encoding).

javascript: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.images; 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)
You can also click here to download and cut-and-paste the code in ASCII, no changes needed in this case
Sample pictures:

10 comments ↓

#1 doodo on 09.22.06 at 2:30 am

do not work :(

#2 Pavel Senko on 09.22.06 at 3:18 am

It’s really important to manually replace all four double quotes with single quotes. Without this step it generates javascript error, instead of nice effect.

#3 Itchy the Killer on 09.22.06 at 3:26 am

Makes no sense.

So why didn’t you put the correct code with single quotes on this page?

#4 Pavel Senko on 09.22.06 at 10:58 am

I did. The code is correct.
In fact, it works fine with single or double quotes, BUT, only for plain text. The problem is not in the code, it’s in copy-paste step.
When it copied from HTML page to address line, quotes got replaced with some other UTF-8 symbols, which look like quotes.

#5 mmmm on 09.22.06 at 2:09 pm

it works with internet explorer 7.0! replaced double quotes with single quotes (all 4 of them), then hit END button, then pressed ENTER.

#6 Evgeniy on 09.22.06 at 2:15 pm

Still does not work. May be it’s better to make this script as a link so everybody could click at it? Firefox 1.5.0.7 at Windows and 1.5.0.6 at Linux doesn’t work. M$IE surely works…
AFAIK Firefox does it right when it refuses to work. Properties “top” and “left”, their values to be correct, must be set not only with numbers, but supplied with unit definitions also, so concatenate it with ‘px’ string like this: Math(…)+…+’px’, that way you’ll set it right.
Anyway, address string is not working, but my standalone local test page is. Make javascript a clickable link (start), replacing all double quotes with single ones.

#7 Pavel Senko on 09.22.06 at 4:49 pm

Evgeniy, Thanks for suggestions! I appreciate your inputs!

#8 andy on 09.24.06 at 1:17 am

works fine in Safari and Firefox on OS X tiger :-)

#9 Mark on 09.25.06 at 11:32 am

Works fine for me. Just remember to double-check that all are single quotes, not backwards single quotes.

Perhaps this script can be made beettr, such as putting in a function to make a single image fly or not? I would be interested in that ;)

#10 Ioan Sameli on 09.26.06 at 6:15 am

Hey, that’s too funny ! Make a bookmarklet with it :p

You must log in to post a comment.