title: How can I grab variable from URL using JavaScript and display it on screen?
body: <p>I am using the following script: </p>
  
  <pre><code>        function getQueryVariable(variable)
  {
         var query = window.location.search.substring(1);
         var vars = query.split("&amp;");
         for (var i=0;i&lt;vars.length;i++) {
                 var pair = vars[i].split("=");
                 if(pair[0] == variable){return pair[1];}
         }
                var id_is = getQueryVariable("id");
  
  document.write(id_is);
  
         return(false);
  
  }
  </code></pre>
  
  <p>This script should grab the variable value and display it on screen.  It only works if I use getQueryVariable("id"); in the console but using the document.write method it doesn't work.  What am I doing wrong?</p>