Javascript 我正在尝试下载SVG内容作为PNG文件。上述代码在Chrome和Firefox浏览器中运行良好。不在IE上工作
我正在尝试下载SVG内容作为PNG文件。上述代码在Chrome和Firefox浏览器中运行良好。不在IE上工作。浏览器控制台中没有错误Javascript 我正在尝试下载SVG内容作为PNG文件。上述代码在Chrome和Firefox浏览器中运行良好。不在IE上工作,javascript,svg,Javascript,Svg,我正在尝试下载SVG内容作为PNG文件。上述代码在Chrome和Firefox浏览器中运行良好。不在IE上工作。浏览器控制台中没有错误 var svg = document.querySelector( "svg" ); var svgData = new XMLSerializer().serializeToString( svg ); var canvas = document.createElement( "canvas" ); var svgSize = svg.getBounding
var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var svgSize = svg.getBoundingClientRect();
canvas.width = svgSize.width;
canvas.height = svgSize.height;
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
ctx.drawImage( img, 0, 0 );
setTimeout(function(){
var a = document.createElement("a");
a.download = "networkmap.png";
a.href = canvas.toDataURL("image/png");console.log(a.href);
document.body.appendChild(a);
a.click();
}, 500);
};
你能提供你使用的IE版本的信息吗?你可以用我的下载工具在IE中下载一个dataURL:eg,
download(“数据:text/plain,hello%20world”,“dlDataUrlText.txt”,“text/plain”)代码>我正在使用IE11版本