【发布时间】:2012-10-06 16:47:57
【问题描述】:
我正在尝试调用我插入的 html 数据中存在的一个 javascript 函数,但我总是收到错误 getLoaded is not a method。我附上了代码sn-p。怎么了?
<canvas width="100%" height="100%" >
<simplelayout axis="y" spacing="2"/>
<button>Set HTML
<handler name="onclick">
<![CDATA[
if (canvas.main) {
canvas.main.setAttribute('html', '<html><head><style type="text/css">body {background-color: #ffffff;}</style><script>function getLoaded(){ return document.images.length;}</script></head><body><img id="imageTag" ></img></body></html>');
}
]]>
</handler>
</button>
<button>test
<handler name="onclick">
<![CDATA[
if (canvas.main) {
var del = new LzDelegate(this,'handlerFunc');
canvas.main.callJavascript('getLoaded',del);
}
]]>
</handler>
</button>
<method name="handlerFunc" args="retVal">
console.log("handlerFunc", retVal);
</method>
<html name="main" x = "50" y="50" width="600" height="400" >
<handler name="oninit">
this.bringToFront();
</handler>
</html>
</canvas>
【问题讨论】:
-
您使用的是 SWF 还是 DHTML 运行时?
-
@RajuBitter:我使用的是 swf 环境。
-
我已经更新了示例以支持 SWF 运行时。
标签: dhtml openlaszlo lzx