Results 1 to 5 of 5

Thread: Can you identiy what the snippet does

  1. #1
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828

    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
    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
    It redirects the site. I beleive if r is greater than 49, then the site will redirect to the site above.

  4. #4
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    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. 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, 00:33 AM
  2. Replies: 3
    Last Post: 20 July, 2010, 12: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
  •