0

How can I make this code to work in firefox 3.6?

Its working in the latest Chrome and Firefox browsers but not for the old firefox 3.6 which is a requirement for my project.

Advance thanks for answering.

(function($) {
  $(document).ready(function() {
    function downloadInnerHtml(filename, elId, mimeType) {
      var elHtml = document.getElementById(elId).innerHTML;
      var link = document.createElement('a');
      mimeType = mimeType || 'application/octet-stream';

      link.setAttribute('download', filename);
      link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
      link.style.cssText = "position: aboslute !important; left: -9999px; visibility: hidden;"; //hide element
      link.innerHTML = "text";
      document.body.appendChild(link);
      link.click();
      setTimeout(function() {
        document.body.removeChild(link); //remove element
      }, 1);
    }

    var fileName = 'logfile.txt'; // You can use the .txt extension if you want

    $('#downloadLink').click(function() {
      downloadInnerHtml(fileName, 'main', 'text/plain');
    });
  });
})(jQuery);
Pete
  • 57,112
  • 28
  • 117
  • 166
user3913971
  • 13
  • 1
  • 4

1 Answers1

0

I'm a bit confused by the version naming from Mozilla Corporation, but from what I see, Firefox 3.6 does not support Data URI

halfzebra
  • 6,771
  • 4
  • 32
  • 47