我需要编辑(使用javascript)嵌入在html页面中的SVG文档.
加载SVG后,我可以访问SVG及其元素的dom.但我无法知道SVG dom是否准备就绪,因此我无法在加载html页面时对SVG执行默认操作.
要访问SVG dom,我使用以下代码:
var svg = document.getElementById("chart").getSVGDocument();
Run Code Online (Sandbox Code Playgroud)
其中"chart"是embed元素的id.
如果我在html文档准备就绪时尝试访问SVG,这样:
jQuery(document).ready( function() {
var svg = document.getElementById("chart").getSVGDocument();
...
Run Code Online (Sandbox Code Playgroud)
svg始终为null.我只需要知道它何时不为空,所以我可以开始操纵它.你知道有没有办法做到这一点?