Cesium信息框不能执行js语句解决办法

    技术2022-07-12  77

    在做BIM模型时需要添加按钮,

    description: “

    设备名称:” + v.name + “

    设备编号:” + v.code+</p><p><button id='jk' onclick="$('#jk').remove()">查看监控</button></p> ,

    提示错误Blocked script execution in ‘about:blank’ because the document’s frame is sandboxed and the ‘allow-scripts’ permission is not set.

    一、这个错误提示是沙箱iframe不允许使用js

    二、解决方法有两个:

    1.禁用infobox,自己设计信息面板。

    2.设置沙箱的权限

    var iframe = document.getElementsByClassName(‘cesium-infoBox-iframe’)[0];

    iframe.setAttribute(‘sandbox’, ‘allow-same-origin allow-scripts allow-popups allow-forms’); iframe.setAttribute(‘src’, ‘’); //必须设置src为空 否则不会生效

    Processed: 0.009, SQL: 9