title: Writing a string to text file with Javascript
body: <p>We are attempting to save a URL stored in a string to a text file, but we can't seem to get it to work. It will not save into the file, although our testing shows that the function is actually running when it should be.</p>
  
  <p>The code for this is here:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;button onclick="instagramclick()"&gt;Login to instagram&lt;/button&gt;
  &lt;button onclick="myFunction()"&gt;Test Button&lt;/button&gt;
  
  &lt;script&gt;
  
  function myFunction() {
      alert("Hello World");
  }
  
  function instagramclick(){
      alert("button clicked");
      window.location.href = "https://instagram.com/oauth/authorize/?client_id=8a612cd650344523808233c0468c80ed&amp;redirect_uri=http://u-ahmed.github.io/HookedUp/instagram.html&amp;response_type=token";
  }
  
  function WriteDemo(link)
  {
   var fso, f, r;
   var ForReading = 1, ForWriting = 2;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   f = fso.OpenTextFile("database.txt", ForWriting, true);
   f.Write(link);
   f.Close();
   r = f.ReadLine();
  return(r);
  }
  
  window.onload = function writedamnyou(){
  var token = window.location.href.substring(62);
  if (token != ""){
      // document.write(token);
      var link = "https://api.instagram.com/v1/users/self/feed?access_token=" + token;
      // w = window.open('database.txt')
      WriteDemo(link);
    // document.write(stuff);
  
  
  }
  };
  
  &lt;/script&gt;
  &lt;p id="no"&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>