Results 1 to 5 of 5

Thread: Can you identiy what the snippet does

  1. #1
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts

    Can you identiy what the snippet does

    Wondering if anyone could tell me what this snippet of code does

    Code:
    <script>
    var r = Math.random();
    r=r*50;
    if(r>49)
    document.location.href="http://www.example.com/somefile.htm";
    </script>

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  2. #2
    elbandelero's Avatar
    elbandelero is offline Net Builder
    Join Date
    Dec 2008
    Location
    Spain
    Posts
    544
    Thanks
    209
    Thanked 106 Times in 80 Posts
    It looks like it's randomly redirecting site visitors to another page, but only if the lucky draw number is greater than 49, which I assume it would be in most cases since r is a randomly picked number to begin with.

  3. #3
    5starpix's Avatar
    5starpix is offline Senior Net Builder
    Join Date
    Dec 2008
    Location
    Montreal, Quebec
    Posts
    1,710
    Blog Entries
    9
    Thanks
    158
    Thanked 227 Times in 164 Posts
    It redirects the site. I beleive if r is greater than 49, then the site will redirect to the site above.

  4. #4
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    What if it was put like this providing this is the correct format what would this do

    Code:
    <script>document.write<script>
    var r = Math.random();
    r=r*50;
    if(r>49)
    document.location.href="http://www.example.com/somefile.htm";
    </script>;</script>

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  5. #5
    Will.Spencer's Avatar
    Will.Spencer is offline Retired
    Join Date
    Dec 2008
    Posts
    5,033
    Blog Entries
    1
    Thanks
    1,010
    Thanked 2,329 Times in 1,259 Posts
    This commented version actually works and you can watch it's output.
    Code:
    <script>
    // Generate a random number between 0 and 1
    var r = Math.random();
    // Print the random number
    document.write(r);
    // Print a hyphen to separate this number from the next number
    document.write(" - ");
    // Multiply the number times fifty, to make a number between 0 and 49.9999999999~
    r=r*50;
    // Print the new random number
    document.write(r);
    // If the random number is 49 or higher, load somefile.htm; If not -- do nothing
    if(r>49)
    document.location.href="http://www.example.com/somefile.htm";
    </script>
    In effect, it loads somefile.htm 2% of the time. This code is probably used for cookie stuffing.
    Submit Your Webmaster Related Sites to the NB Directory
    I swear, by my life and my love of it, that I will never live for the sake of another man, nor ask another man to live for mine.

Similar Threads

  1. Rich Snippet Testing Tool
    By tmongy in forum Building
    Replies: 0
    Last Post: 21 September, 2010, 01:33 AM
  2. Replies: 3
    Last Post: 20 July, 2010, 13:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

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