Jquery Download script only works in Chrome

I have copied a jquery script from another source and the run it. It seems to be working fine but I noticed that the function doesn’t work in Mozilla Firefox and other browsers. Here’s the code:

var $j = jQuery.noConflict();
$j(document).ready(function () {

              //Get a reference to the link on the page
              // with an id of "exportxt"
              var a = document.getElementById("exportxt");

              //Set code to run when the link is clicked
              // by assigning a function to "onclick"
              a.onclick = function() {
    function downloadInnerHtml(filename, elId, mimeType) {
        var elHtml = $('#codeoutput').val();
        var link = document.createElement('a');
        mimeType = mimeType || 'text/plain';
        link.setAttribute('download', filename);
        link.setAttribute('href', 'data:' + mimeType  +  ';charset=utf-8,' + encodeURIComponent(elHtml));
    var fileName =  'schema.txt';
    downloadInnerHtml(fileName, 'codeoutput','text/plain');
                return false;


Thank you

$ is not defined through the use of $.noConflict(). that should have emitted a message in the error console.

Hi, thanks for your help. So I changed it to var elHtml = $j('#codeoutput').val(); is that what you are referring to? if yes, it didn’t work either. :disappointed_relieved:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.