【发布时间】:2020-06-20 15:22:58
【问题描述】:
我有以下代码。我面临在警报中收到未定义的问题。有人知道为什么吗?
<div><button class='hello' value='hello1'>Show</button></div>
viewer.infoBox.frame.addEventListener('load', function() {
// Now that the description is loaded, register a click listener inside
// the document of the iframe.
viewer.infoBox.frame.contentDocument.body.addEventListener('click', function(e) {
// The document body will be rewritten when the selectedEntity changes,
// but this body listener will survive. Now it must determine if it was
// one of the clickable buttons.
alert(e.target.value);
}, false);
}, false);
更新:我设法让它在这个sandbox 上工作,但无法在本地主机上这样做。有什么想法吗?
【问题讨论】:
-
什么是 viewer.infoBox.frame - 请点击编辑和
[<>]sn-p 编辑器并提供minimal reproducible example -
@mplungjan 我已经更新了一个例子。
-
不知道。对不起。
标签: javascript iframe target cesium