Internet Explorer - DOM7011: The code on this page disabled back and forward caching. Warning after trying to download Binary Files with Javascript

13,313

I've managed to solve my own problem and now I'll post the solution here to help others with the same problem.

I couldn't download files on IE. On other browsers like Chrome, Firefox and Opera was working fine. I searched a lot and even posted my problem here on StackOverflow although no one could help me find the answer.

I found this script that helped me.

The code is from dandavis and can be found here:
http://danml.com/download.html
https://github.com/rndme/download

Hope you can find it useful!

Share:
13,313
Ricardo Cerdeira
Author by

Ricardo Cerdeira

Updated on June 05, 2022

Comments

  • Ricardo Cerdeira
    Ricardo Cerdeira over 1 year

    So, I'm trying to download binary files with javascript. It works fine on Chrome and Opera but doesn't work on IE.

    After trying to download the files the warning "DOM7011: The code on this page disabled back and forward caching." appears on IE Developer Tools.

    Does anyone already had this problem?

    $.DownloadBase64File = function (file, data) {
        if (file && data) {
            var link = document.createElement('a');
            link.setAttribute('href', "data:application/octet-stream;charset=utf-16le;base64," + encodeURIComponent(data));
            link.setAttribute('download', file);
            link.click();
        };
    };
    
    if (data.status === '0') {
        $.DownloadBase64File(
            'MyPDF_File.pdf',
            data.ReportBinary
        );
    }
    

    Appretiate your help :)

  • Kyll
    Kyll almost 5 years
    While this link might provide some limited, immediate help, an answer should include sufficient context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, to make it more useful to future readers with other, similar questions. In addition, other users tend to respond negatively to answers which are barely more than a link to an external site, and they might be deleted.