如何让这段代码在firefox 3.6中运行?
它在最新的Chrome和Firefox浏览器中工作,但不适用于旧版本 firefox 3.6这是我项目的要求。
感谢您的回答。
(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);