jeudi 28 janvier 2016

Generate Random URL, but URL length can't be changed fro some reason?

As of recently I've been working on a site as a bit of a hobby during class. On this site there is some basic text a single button and a text field. when you press the button it generates a random URL and then you can add your own extension to it. At the moment it's to send people to random .onion domains. My current problem is that I cant get the length of the URL to be set to a random length. Here is my code, if you can recommend a fix that would be great. `

<body>
  <script>
    var 'x' = Math.random() * 20
  </script>
  <script language="javascript" type="text/javascript">
    function randomString() {
      var chars = "0123456789abcdefghiklmnopqrstuvwxyz";
      var string_length = 'x';
      var randomstring = '';
      for (var i = 0; i < string_length; i++) {
        var rnum = Math.floor(Math.random() * chars.length);
        randomstring += chars.substring(rnum, rnum + 1);
      }
      document.randform.randomfield.value = randomstring;
    }
  </script>
  <form name="randform">
    <input type="button" value="Generate A New Base URL" onClick="randomString();">&nbsp;
    <input type="text" name="randomfield" value="">
  </form>
</body>



Aucun commentaire:

Enregistrer un commentaire