View Full Version : looking for a specific java script code

12-10-2011, 12:24 AM
hello, i am looking a a specific javascript code for a school project. what the code does is it re-sizes your window to a specific size, and then makes it jump around to the four corners of your screen. a perfect example of this would be the rick roll site called
its best viewed in internet explorer, and will take effect after you allow it on the top pop up window. it seems that the latest version of firefox disables the window resizing and movement, so use IE. after examining the page source, i managed to find this code.

for (i = 1; i <= 9; i++){
setTimeout('window.moveTo(1599,1199);', i+"000");
setTimeout('window.moveTo(0,1199);', i+"000");
setTimeout('window.moveTo(1599,0);', i+"000");
setTimeout('window.moveTo(0,0);', i+"000");

the code worked perfectly on the macs used at school. but however, when i took it home and tried it on my PC, which has a different sized monitor, it didnt work right. my copied code section seemed to jump off the edges of the screen, like it was using the size of a Macs monitor, yet the original website works fine. this led me to believe that the source code seems to find the size of the monitor and adjust the position of where it moves. i cant seem to find that part of the code. any help would be appreciated

Old Pedant
12-10-2011, 03:53 AM
No, the source code is *ASSUMING* the size of the Mac monitor.

That's why all the moveTo() numbers are *HARD CODED*. They aren't calculated, at all.

window.resizeTo() doesn't work in MSIE 9 or Chrome. It does work on FF3.x.

I'm not sure there is a universal function that allows you to resize a window. You *could*, however, open a *new* window of a specified size in any browser.

12-10-2011, 05:04 AM
why is it then that when i wrote the code on a mac, by copying it directly from the source, it worked, and bringing it home made it not work properly, yet the website i got the source from works fine on both computers. i must be missing something important somewhere.

Old Pedant
12-10-2011, 05:20 AM
Show the website URL. I hope you don't mean that rickroll site. I'm not touching it again! Only way I could kill it was with task manages, and then it closed all my Firefox windows. That site is *EVIL*. It should be banned.

12-10-2011, 06:01 AM
unfortunately the rickroll site does exactly what i need. i haven't found another since. an easy way to exit it, is to wait for it to stop moving. it will stop dancing after it makes about 4 or 5 complete rotations, and then you can close the tab easy. it will try and sing the whole song to you before you leave, but sometimes you can click, a box that says "prevent this page from creating additional dialogue boxes" and that will stop the script. otherwise just hold enter and it will go through them really fast and exit after its done.

Old Pedant
12-10-2011, 06:38 AM
Well, I *did* do a VIEW==>>SOURCE on it, and it's got a *LOT* more code in there for resizing/moving than what you showed. Maybe you can figure out what parts to use.

12-10-2011, 07:19 AM
thats what i figured, but im still only in my first year of web design, so i have no idea what most of that code means. my main question was if anyone could help me by directing me to the rest of the resizing and movement in the source code