cesium 的infoBox不能执行js脚本

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013821237/article/details/80067192

一、分析:因为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');


猜你喜欢

转载自blog.csdn.net/u013821237/article/details/80067192
今日推荐