title: How to write a text document in new tab / window?
body: <p>Below code is used to display the image in new tab if the extension is jpg.</p>
  
  <p>Similarly, I want to write a text document <em>(from base64 string to text)</em> in new tab if the extension is txt.</p>
  
  <pre><code>success: function (data) {
              var extension = fileName.split('.').pop();
              if (extension == "jpg") {
                  var image = new Image();
                  image.src = "data:image/jpg;base64," + data.d;
                  var w = window.open("");
                  w.document.write(image.outerHTML);
              }
              else if(extension == "txt") {
  
              }
      }
  </code></pre>