Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    looking for a specific java script code

    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
    http://www.20b.org/rickroll.html
    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.

    window.resizeTo(640,625);
    window.moveTo(0,0);
    for (i = 1; i <= 9; i++){
    setTimeout('window.moveTo(1599,1199);', i+"000");
    i++;
    setTimeout('window.moveTo(0,1199);', i+"000");
    i++;
    setTimeout('window.moveTo(1599,0);', i+"000");
    i++;
    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
    Last edited by coloneldean; 12-09-2011 at 11:33 PM.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,585
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,585
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    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.
    Last edited by Old Pedant; 12-10-2011 at 04:24 AM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,585
    Thanks
    80
    Thanked 4,497 Times in 4,461 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •