www.webdeveloper.com
Results 1 to 10 of 10

Thread: why wont this code work

  1. #1
    Join Date
    Jun 2013
    Posts
    10

    Question why wont this code work

    this code worked before but for some reason after i added new websites its stopped working whats wrong with it!!!

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    is this a kind of a secret invisible code?

  3. #3
    Join Date
    Jun 2013
    Posts
    10
    i dint post the code sorry here it is: <script>
    var links=new Array()

    links[0]="http://www.kongregate.com"
    links[1]="http://www.youtube.com"
    links[2]="http://www.armorgames.com"
    links[3]="http://www.minecraft.net"
    links[4]="http://playmcfree.webs.com"
    links[5]="http://www.Demoscene.tv"
    links[6]="http://www.Letsplayarchive.com"
    links[7]="http://www.Soyouwanna.com"
    links[8]="http://www.Whatshouldireadnext.com"
    links[9]="http://www.bing.com"
    links[10]="http://www.amazon.com"
    links[11]="http://www.wikipedia.com"
    links[12]="http://www.twitter.com"
    links[13]="http://www.ask.com"
    links[14]="http://www.msn.com"
    links[15]="http://www.ebay.com"
    links[16]="http://www.wordpress.com"
    links[17]="http://www.tumblr.com"
    links[18]="http://www.hulu.com"
    links[19]="http://www.craigslist.org"
    links[20]="http://www.instagram.com"
    links[21]="http://www.paypal.com"
    links[22]="http://www.about.com"
    links[23]="http://www.flikr.com"
    links[24}="http://www.netflix.com"
    links[25]="http://www.stackoverflow.com"
    links[26]="http://www.cnet.com"
    links[27]="http://www.softonic.com"
    links[28]="http://www.redit.com"
    links[29]="http://www.mediafire.com"
    links[30]="http://www.4shared.com"





    function randomlink(){
    window.location=links[Math.floor(Math.random()*links.length)]
    }

    </script>
    <form>
    <p><input type="button" name="B1" value="click to go to random websites" onclick="randomlink()"/></p>disclaimer: I do not own any of these websites.</form>

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    did you see my signature? this is colored ))

  5. #5
    Join Date
    Jun 2013
    Posts
    10
    here is the code:
    Code:
    <script>
    var links=new Array()
    
         links[0]="http://www.kongregate.com"
          links[1]="http://www.youtube.com"
           links[2]="http://www.armorgames.com"
            links[3]="http://www.minecraft.net"
             links[4]="http://playmcfree.webs.com"
              links[5]="http://www.Demoscene.tv"
                links[6]="http://www.Letsplayarchive.com"
                  links[7]="http://www.Soyouwanna.com"
                   links[8]="http://www.Whatshouldireadnext.com"
                     links[9]="http://www.bing.com"
                       links[10]="http://www.amazon.com"
                         links[11]="http://www.wikipedia.com"
                           links[12]="http://www.twitter.com"
                             links[13]="http://www.ask.com"
                               links[14]="http://www.msn.com"
                                 links[15]="http://www.ebay.com"
                                   links[16]="http://www.wordpress.com"
                                     links[17]="http://www.tumblr.com"
                                       links[18]="http://www.hulu.com"
                                         links[19]="http://www.craigslist.org"
                                           links[20]="http://www.instagram.com"
                                             links[21]="http://www.paypal.com"
                                               links[22]="http://www.about.com"
                                                 links[23]="http://www.flikr.com"
                                                   links[24}="http://www.netflix.com"
                                                     links[25]="http://www.stackoverflow.com"
                                                       links[26]="http://www.cnet.com"
                                                         links[27]="http://www.softonic.com"
                                                           links[28]="http://www.redit.com"
                                                             links[29]="http://www.mediafire.com"
                                                               links[30]="http://www.4shared.com"
                                                                 
          
    
    
    
    function randomlink(){
    window.location=links[Math.floor(Math.random(30)*links.length)]
    }
      
    </script>
    <form>
      <p><input type="button" name="B1" value="click to go to random websites" onclick="randomlink()"/></p>disclaimer: I do not own any of these websites.</form>

  6. #6
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>bla-bla-bla</title>
    <script type="text/javascript">
    var links=[
    "http://www.kongregate.com",
    "http://www.youtube.com",
    "http://www.armorgames.com",
    "http://www.minecraft.net",
    "http://playmcfree.webs.com",
    "http://www.Demoscene.tv",
    "http://www.Letsplayarchive.com",
    "http://www.Soyouwanna.com",
    "http://www.Whatshouldireadnext.com",
    "http://www.bing.com",
    "http://www.amazon.com",
    "http://www.wikipedia.com",
    "http://www.twitter.com",
    "http://www.ask.com",
    "http://www.msn.com",
    "http://www.ebay.com",
    "http://www.wordpress.com",
    "http://www.tumblr.com",
    "http://www.hulu.com",
    "http://www.craigslist.org",
    "http://www.instagram.com",
    "http://www.paypal.com",
    "http://www.about.com",
    "http://www.flikr.com",
    "http://www.netflix.com",
    "http://www.stackoverflow.com",
    "http://www.cnet.com",
    "http://www.softonic.com",
    "http://www.redit.com",
    "http://www.mediafire.com",
    "http://www.4shared.com"
    ];
    
    function randomlink(){
    window.location=links[Math.floor(Math.random()*links.length)];
    }
    </script>
    </head>
    <body>
    <form>
    <p><input type="button" name="B1" value="click to go to random websites" onclick="randomlink()"/></p>
    disclaimer: I do not own any of these websites.</form>
    </body>
    </html>

  7. #7
    Join Date
    Jun 2013
    Posts
    10
    thanks it worked

  8. #8
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    good to hear )

  9. #9
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by html/java/php View Post
    thanks it worked
    This line was the problem, but I didn't spot it:

    Code:
    links[24}="http://www.netflix.com"
    Use the error console.

  10. #10
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    the less similar brackets per square inch of the code, the better <wink>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles