Hello,
I’m developing a digital twin application using CesiumJS and I’m facing a persistent issue with the InfoBox security. I’m trying to display external content within the InfoBox using an <iframe>, but I keep getting the following error in the console:
Blocked script execution in '...' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
Context Details:
-
CesiumJS Version: 1.131.0
-
Goal: Display content from an external URL (e.g., a dashboard or a YouTube video) inside an
InfoBoxthat appears when a pin is clicked. -
Implementation: I am creating an entity (pin) and setting its
descriptionproperty with HTML that contains an<iframe>.
Attempts to Fix: I have tried several solutions based on the documentation and community discussions, but none have worked:
-
Cesium.ViewerConfiguration: I added aninfoBoxproperty to theviewerconfiguration to explicitly allow scripts.JavaScript
const viewer = new Cesium.Viewer('cesiumContainer', { infoBox: { sanitize: false, sandbox: "allow-scripts allow-same-origin allow-popups" }, // ... other configurations });This did not resolve the issue.
-
Adding the
sandboxAttribute Directly to the<iframe>: I tried adding thesandbox="allow-scripts allow-same-origin allow-popups"attribute directly to the<iframe>tag within the HTML string for the entity’s description.HTML
<iframe src="..." sandbox="allow-scripts allow-same-origin allow-popups"></iframe>This solution also did not work, which leads me to suspect that the main
InfoBoxiframeitself is blocking the scripts, not theiframeI created.
My Questions:
Is there a definitive way to configure the InfoBox so that an embedded iframe can run scripts correctly? Is there a configuration change or a method I might be missing? Are there any other security limitations of Cesium or modern browsers that I should be aware of?
I would greatly appreciate any advice or solutions from the community. Thank you very much!