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でファイル全体を取得するにはどうすればよいですか?
ありがとう、これは両方のブラウザで動作しました。 –