在Vimperator中,当我点击gf它时,我需要查看源代码.如何退出查看源并返回实际网页?
我正在尝试将 svg 转换为图像并提示用户下载。
var chart = $(svg.node())
.attr('xmlns', 'http://www.w3.org/2000/svg');
var width = that.svg_width;
var height = that.svg_height;
var data = new XMLSerializer().serializeToString(chart.get(0));
var svg1 = new Blob([data], { type: "image/svg+xml;charset=utf-8" });
var url = URL.createObjectURL(svg1);
var img = $('<img />')
.width(width)
.height(height);
img.attr('crossOrigin' ,'' );
img.bind('load', function() {
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
ctx.drawImage(img.get(0), 0, 0);
canvas.toBlob(function(blob) { // this is where it fails
saveAs(blob, "test.png");
});
});
img.attr('src', url);
Run Code Online (Sandbox Code Playgroud)
Chrome …