# Stupid javascript trick

**URL:** <https://boards.straightdope.com/t/stupid-javascript-trick/387237>\
**Category:** Miscellaneous and Personal Stuff I Must Share\
**Created:** [January 9, 2007, 1:33am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237 "2007-01-09T01:33:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [January 9, 2007, 1:33am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/1 "2007-01-09T01:33:32Z")

</div>

Copy the code below into your address bar and all the images on this page will dance around. You’ll have to remove the line break that I added in to prevent anyone’s browser from accidentally executing it.

```auto

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.i
mages; 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; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0); 

```

Here are some images to watch dance:

🙂 :rolleyes: 🆒😛 :dubious: 😉 :smack: 😃😕 :o :eek: ☹ :mad:

---

<div class="post-metadata">

**Author:** ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)\
**Post date:** [January 9, 2007, 1:38am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/2 "2007-01-09T01:38:53Z")

</div>

Doesn’t work right for me. It bunches up all the smilies in one spot and that’s it. Windows XP, Firefox 1.5 browser.

---

<div class="post-metadata">

**Author:** ![SSG\_Schwartz](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@SSG\_Schwartz](https://boards.straightdope.com/u/SSG_Schwartz)\
**Post date:** [January 9, 2007, 1:41am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/3 "2007-01-09T01:41:15Z")

</div>

Pretty cool trick. I ran it on Opera and it worked fine.

Sgt Schwartz

---

<div class="post-metadata">

**Author:** ![Mindfield](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mindfield/32/19759_2.png) [@Mindfield](https://boards.straightdope.com/u/Mindfield)\
**Post date:** [January 9, 2007, 1:43am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/4 "2007-01-09T01:43:27Z")

</div>

Looks like it’s happier in IE. Doesn’t work in Firefox, not even with the IE-Tab extension. Works fine in IE though.

---

<div class="post-metadata">

**Author:** ![Captain\_Carrot](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Captain\_Carrot](https://boards.straightdope.com/u/Captain_Carrot)\
**Post date:** [January 9, 2007, 2:11am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/5 "2007-01-09T02:11:30Z")

</div>

Didn’t work for me in IE or FF 1.5.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [January 9, 2007, 2:23am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/6 "2007-01-09T02:23:55Z")

</div>

[QUOTE=Captain Carrot]  
Didn’t work for me in IE or FF 1.5.  
[/QUOTE]

What version of IE are you using?

---

<div class="post-metadata">

**Author:** ![Captain\_Carrot](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Captain\_Carrot](https://boards.straightdope.com/u/Captain_Carrot)\
**Post date:** [January 9, 2007, 2:31am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/7 "2007-01-09T02:31:49Z")

</div>

I think it’s 6; I know we haven’t downloaded 7. How can I find out for sure?

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [January 9, 2007, 2:33am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/8 "2007-01-09T02:33:45Z")

</div>

Try appending **+“px”** to the DIS.top and DIS.left assignments. (These are CSS styles, which according to the standards require units, unlike HTML where pixel values are often given with no units.) That is:

```auto

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.i
mages;DIL=DI.length;function A(){for(i=0; i-DIL; i++){DIS=DI*.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);

```

---

<div class="post-metadata">

**Author:** ![IrreverentTone](https://avatars.discourse-cdn.com/v4/letter/i/b487fb/32.png) [@IrreverentTone](https://boards.straightdope.com/u/IrreverentTone)\
**Post date:** [January 9, 2007, 2:36am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/9 "2007-01-09T02:36:03Z")

</div>

That is wild. It works for me in IE 6.0 and FF 2.0.0.1. [www.lileks.com](http://www.lileks.com) works nauseatingly well!

---

<div class="post-metadata">

**Author:** ![IrreverentTone](https://avatars.discourse-cdn.com/v4/letter/i/b487fb/32.png) [@IrreverentTone](https://boards.straightdope.com/u/IrreverentTone)\
**Post date:** [January 9, 2007, 2:38am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/10 "2007-01-09T02:38:44Z")

</div>

Whoops the one place that it doesn’t work is on the dope in Firefox. IE is fine.

---

<div class="post-metadata">

**Author:** ![Sunspace](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/sunspace/32/1250_2.png) [@Sunspace](https://boards.straightdope.com/u/Sunspace)\
**Post date:** [January 9, 2007, 2:41am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/11 "2007-01-09T02:41:24Z")

</div>

The second version works for me in FF 2.0. That is …mindblowing.

I have go to figure out how it works, and then annoy my friends when they visit my webpages. 😃

---

<div class="post-metadata">

**Author:** ![Q.E.D](https://avatars.discourse-cdn.com/v4/letter/q/51bf81/32.png) [@Q.E.D](https://boards.straightdope.com/u/Q.E.D)\
**Post date:** [January 9, 2007, 2:41am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/12 "2007-01-09T02:41:32Z")

</div>

[QUOTE=Omphaloskeptic]  
Try appending **+“px”** to the DIS.top and DIS.left assignments. (These are CSS styles, which according to the standards require units, unlike HTML where pixel values are often given with no units.)  
[/QUOTE]

Bingo. That fixed it for me.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [January 9, 2007, 2:42am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/13 "2007-01-09T02:42:27Z")

</div>

[QUOTE=Captain Carrot]  
I think it’s 6; I know we haven’t downloaded 7. How can I find out for sure?  
[/QUOTE]

Help \> About Internet Explorer will show you the version number.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [January 9, 2007, 2:43am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/14 "2007-01-09T02:43:41Z")

</div>

[QUOTE=Omphaloskeptic]  
Try appending **+“px”** to the DIS.top and DIS.left assignments. (These are CSS styles, which according to the standards require units, unlike HTML where pixel values are often given with no units.) That is:

```auto

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.i
mages;DIL=DI.length;function A(){for(i=0; i-DIL; i++){DIS=DI*.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);

```

[/QUOTE]

I’m surprised it worked in Opera then. Thanks for the fix.

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [January 9, 2007, 4:17am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/15 "2007-01-09T04:17:03Z")

</div>

All my browser does is “boop”. Page doesn’t change. Shiira 1.2.1, OS X 10.4.8

---

<div class="post-metadata">

**Author:** ![AHunter3](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ahunter3/32/368_2.png) [@AHunter3](https://boards.straightdope.com/u/AHunter3)\
**Post date:** [January 9, 2007, 4:20am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/16 "2007-01-09T04:20:46Z")

</div>

Firefox doesn’t do anything with it either.

Nor Opera.

---

<div class="post-metadata">

**Author:** ![myskepticsight](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@myskepticsight](https://boards.straightdope.com/u/myskepticsight)\
**Post date:** [January 9, 2007, 5:27am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/17 "2007-01-09T05:27:50Z")

</div>

Safari made everything move around in circles. 'Twas odd.

---

<div class="post-metadata">

**Author:** ![space\_fish](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@space\_fish](https://boards.straightdope.com/u/space_fish)\
**Post date:** [January 9, 2007, 6:04am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/18 "2007-01-09T06:04:29Z")

</div>

Made a bookmarklet of it. Now to have some fun with google image search.

---

<div class="post-metadata">

**Author:** ![ZipperJJ](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/zipperjj/32/211_2.png) [@ZipperJJ](https://boards.straightdope.com/u/ZipperJJ)\
**Post date:** [January 9, 2007, 6:45am UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/19 "2007-01-09T06:45:34Z")

</div>

That is really f’n weird, dude. How (why) on earth did you come up with that?

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [January 9, 2007, 1:44pm UTC](https://boards.straightdope.com/t/stupid-javascript-trick/387237/20 "2007-01-09T13:44:19Z")

</div>

[QUOTE=ZipperJJ]  
That is really f’n weird, dude. How (why) on earth did you come up with that?  
[/QUOTE]

I can’t claim credit for this one. I saw it on another message board and thought it might be entertaining to share.

I didn’t realize that you could type code into the address bar like that and modify the current page. I will have to play around with this a bit.

[Next page](https://boards.straightdope.com/t/stupid-javascript-trick/387237.md?page=2)
