It will show up as a separate document, similar to an iframe. You can access it like this:
var svg = document.getElementById('graphics').contentDocument
Note that it is important to wait until the svg file is loaded; you might want to put your code in the object
element’s onload
event handler, like this:
<object data="graphics.svg" type="image/svg+xml" id="graphics" />
<script>
document.getElementById('graphics').addEventListener('load',function(){
var svg = document.getElementById('graphics').contentDocument
// do stuff, call functions, etc.
})
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…