我在我的HTML文档中包含了一个带有<embed src="mySvg.svg" />
的SVG文件,现在我想操纵SVG中的内容。访问HTML文件中包含的SVG文件
我发现SVG不在“文档”中,而是在“窗口”中。
在我的SVG文件,我有一个脚本:
(在推出的onload初始化函数)
function init(evt) {
svgDocument = evt.target.ownerDocument; svgDocument.getElementById('anIdOfMySvgFile'); // I successfully get the element of the SVG file
this.parent.document.getElementById('anIdOfMyHtmlFile'); // I successfully get the element of the HTML file
}
但我怎么能选择我的SVG文件与位于我的HTML文件的脚本元素?
window.document是我的HTML文件...但我不知道我的SVG文件是如何识别的!
可能重复的[如何访问HTML中“嵌入”标记的内容](http://stackoverflow.com/questions/8496241/how-to-access-the-content-of-the -embed-tag-in-html) – 2012-01-01 12:38:51