一、分析:因为infoBox是Ifram框架,H5的新安全机制不允许在其中执行脚本,如果在里面写了类似于点击事件的脚本,则会提示如下错误:Blocked script execution in 'about:blank' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
二、解决方法有两个:
1.禁用infobox,自己设计信息面板。
2.设置沙箱的权限
var iframe = document.getElementsByClassName('cesium-infoBox-iframe')[0];
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups allow-forms');
本文分析了在Ifram框架infoBox中执行脚本时遇到的安全限制问题,并提供了两种解决方案:一是禁用infoBox并自行设计信息面板;二是通过设置iframe的sandbox属性来允许脚本执行。

8048

被折叠的 条评论
为什么被折叠?



