问题描述
我尝试从在Internet Explorer和Safari浏览器上绘制SVG图像的画布上检索数据URL时遇到以下错误,而其他人正常工作。
I am getting the following error while trying to retrieve the data URL from a canvas on which an SVG image is drawn on Internet Explorer and Safari browsers while the others are working properly.
此外,SVG图像包含一些< image>
元素,其中 xlink:href
属性已设置从用户的文件系统读取的图像作为数据URL。由于这些图像不在不同的域上,因此在尝试获取绘制SVG图像的画布的dataURL时,我无法想到为什么会抛出此错误。在此先感谢。
In addition, the SVG image contains some <image>
elements whose xlink:href
attributes are set to images read from the user's file system as data URLs. Since these images are not located on different domains, i could not think of any reason why this error is thrown when trying to get the dataURL of the canvas on which the SVG image is drawn. Thanks in advance.
推荐答案
我可以使用我的测试用例在Internet Explorer 11中确认此问题制作:
I can confirm this issue in Internet Explorer 11 using a test case that I made:
http://jsfiddle.net/tsbXW/
这是Microsoft正在开发的Internet Explorer的已知限制:
This is a known limitation of Internet Explorer that Microsoft is working on:
https://connect.microsoft.com/IE/feedback/details/828416/cavas-todataurl-method-doesnt-work-after-draw-svg-file-to-canvas
如错误报告所示,绘制到画布中的任何 SVG图像会污染画布,在调用toDataURL()时会导致 SecurityError
。
As demonstrated by the bug report, any SVG image drawn into a canvas taints the canvas, causing a SecurityError
when toDataURL() is called.
对于它的价值,bug报告的在Safari 7.0中不起作用.5,或者(据称Apple已经在Safari 8中解决了这个问题)。此外,由于。
For what it's worth, the bug report's test case does not work in Safari 7.0.5, either (though purportedly Apple has fixed the issue in Safari 8). Also, the test case does not work in Firefox until version 11 due to Bug 672013 - Allow SVG-as-an-image to be drawn into a canvas without marking it as write-only.
这篇关于SECURITY_ERR:DOM异常18在调用Canvas的toDataURL方法时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!