2013-08-05 127 views
2

我正在致力于将svg转换为png。对于此转换,我使用canvg。这种转换工作正常与谷歌浏览器,但IE 10提供了以下错误信息。canvg不适用于IE 10

Unhandled exception at line 137, column 5 in http://localhost:21683/Js/canvg.js 

0x800a139e - JavaScript runtime error: SyntaxError 

我试着下面的代码

http://jsfiddle.net/dGzau/

http://jsfiddle.net/fnyJV/

如何使其在IE 10上运行?

任何人都可以请帮助我做到这一点?

+0

你应该在提问时提及你的IE版本。 –

+0

你的小提琴似乎有很多与jQuery和其他东西有关。 这里的答案在http://stackoverflow.com/questions/18085854/print-large-raphael-js-chart-accross-multiple-pages有一个小提琴http://jsfiddle.net/mdYnz/8/使用canvg没有其他库,依赖于'innerHTML'而不是jQuery的'.html()'。 试试这个,并检查它是否有效。如果是的话,那么我会研究为什么你的代码不工作。 –

回答

4

我发现这个改进(http://code.google.com/p/canvg/issues/detail?id=189),并在IE10上正常工作。但我正在寻找一个解决方案的Internet Explorer 10以下。

如果我在'svg.parseXml'函数的开头添加以下行,我的代码现在可以工作。

// -- Internet Explorer trick, otherwise an error is generated in the 'parseFromString' function when 
// -- You use <svg xmlns="http://www.w3.org/2000/svg"></svg> declarations, this is the case for Raphael 
xml = xml.replace(/xmlns=\"http:\/\/www\.w3\.org\/2000\/svg\"/, '');