Roberto Marras
Roberto Marras

Reputation: 153

s.substr is not a function

I am using canvg, but when I run this:

jQuery("#print").on("click", function() {
    mySvg();
});

function mySvg() {
    var svg = jQuery("#map svg");
  canvg(document.getElementById('canvas'), svg);
}

I get this in console

canvg.js:58 Uncaught TypeError: s.substr is not a function

Here it is a jsFiddle

Upvotes: 3

Views: 2827

Answers (1)

JamieMcGrory
JamieMcGrory

Reputation: 71

Siguza is correct, you want to get the inner HTML of your SVG so (assuming #map is the direct parent of your target svg):

var svg = jQuery('#map');
var txt = svg.innerHTML;

Then you want to pass the txt variable as your second canvg() argument.

Upvotes: 3

Related Questions