Workaround for <foreignObject> that is not supported in IE

tuchfeld used Ask the Experts™
Can you please direct me how to do so?
The folowing code works just fine in Chrome.
Thanks, Aryeh.
function html_to_img(html) {
  var data = '<svg xmlns="" width="' + 400 + '" height="' + 200 + '">' +
          '<foreignObject width="100%" height="100%">' +
          '<div xmlns="" style="font-size:18px; font-family: david; word-wrap: break-word;">' +
          html +
          '</div>' +
          '</foreignObject>' +

  var DOMURL = window.URL || window.webkitURL || window;
  var svg = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
  var url = DOMURL.createObjectURL(svg);
  img.src = url; // some Image Element.

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Manager / Solutions Architect
I think this isn't possible.
Have you tried HTML2Canvas?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial