我正在寻找meteor的应用程序,该应用程序使用包含使用对象标记的交互式SVG文件。
我有一个使用静态html / js / SVG文件的运行原型,我可以点击SVG中的一个实体并让我的html页面的Javascript被执行。
但是当我使用meteor调整这个原型时,Javascript范围会发生一些事情,结果是我无法再从SVG中找到html页面的Javascript函数。
流星版的基本结构如下。
app.html:
<head>
<title>test</title>
</head>
<body>
<div id="mySVG" class="container">
<object data="test.svg" type="image/svg+xml"></object>
</div>
</body>
test.svg(放在/ public文件夹中):
<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg" xmlns:se="http://svg-edit.googlecode.com" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>networktest</title>
<g>
...graphics...
</g>
<script>
document.getElementById("foo").addEventListener("click", sendClickToParentDocument, false);
function sendClickToParentDocument(e)
{
if( window.parent.foo)
window.parent.foo( e.target );
else
alert("Bar!");
}
</script>
</svg>
app.js:
function foo( target ) {
// ... do stuff ...
}
现在在流星版中,我得到了&#34; Bar&#34;警告,而不是对foo()的调用。 我在.js中放置了一个定义foo()函数的断点,并在页面加载时调用它,这样就可以了。但显然它并没有像我运行静态文件那样在同一个地方。
如何在SVG中找到它?