我的HTML页面中有一个简单的按钮,用于下载SVG文件。这在Chrome中工作得很好,但在Firefox中,文件只有1行(第一行)。JavaScript下载停止在Firefox中,但在Chrome中工作
$("button").click(function(){
svgSource = phylocanvas.getSvgSource();
console.log(svgSource);
if(svgSource){
var hiddenElement = document.createElement('a');
document.body.appendChild(hiddenElement); // Add the element to the DOM
hiddenElement.setAttribute("type", "hidden"); // make it hidden
hiddenElement.href = 'data:attachment/text,' + encodeURI(svgSource);
hiddenElement.target = '_blank';
hiddenElement.download = '<TMPL_VAR NAME="TREENAME">.svg';
console.log(hiddenElement.download);
hiddenElement.click();
}
});
任何想法如何在Firefox中获取整个文件?
谢谢你,这两个浏览器的工作。 –