当您将来自其他域的图像放在画布中时,画布会受到污染,并且诸如getDataURL或getImageData之类的某些功能会被禁用.
当您尝试使用此类功能时,会发生SECURITY_ERROR错误.
为什么有这种保护措施?这种方法使用了哪种攻击?
谢谢!
编辑:
我应该问:如何将来自其他域的图像用于攻击?
我弄不明白为什么蜂鸣后浏览器限制使用画布.
解决方法:
这是跨域封锁,这类似于事实,您无法从iframe内的页面访问元素,例如…
编辑:
从w3文档中:
Note that the URL given in the ‘src’ or ‘data’ attributes must be on
the same domain as the web page and follows the same domain rule (i.e.
same protocol, port, etc.); cross-domain object insertion is not
supported for security reasons.
但是我碰到了这一点,也许您可以解决一些问题:
http://dev.w3.org/SVG/tools/svgweb/docs/UserManual.html#cross_domain
顺便说一下,Java脚本中的跨域可以在较新的浏览器上运行,但是您需要拥有两个域,并配置连接以使其被视为可信,请参见此处:
http://www.nczonline.net/blog/2010/05/25/cross-domain-ajax-with-cross-origin-resource-sharing/