Receive Uncaught SecurityError when accessing SVG objects from Javascript

前端 未结 1 1258
Happy的楠姐
Happy的楠姐 2020-12-11 05:28

Today I\'ve been spending a bit of time trying to manipulate SVGs with D3 (and jQuery). My goal is being able to access/modify local SVGs through JavaScript. Doesn\

相关标签:
1条回答
  • 2020-12-11 05:39

    In Chrome, it is not possible to access an external SVG's contents via JavaScript when the page is opened through the file system (i.e. the URL has the file:// protocol).

    To get around this, you can open it through a local server. Alternately, you can disable the Same-Origin Policy web security feature for testing using --disable-web-security command line argument. Firefox also does not have this limitation, so there is that option as well.

    0 讨论(0)
提交回复
热议问题