问题
I can normally call a method that is inside the html of an iframe using this approach:
document.getElementById("frame_id").contentWindow.method_in_frame();
I can also call methods outside the iframe using the parent approach:
onclick="parent.method_outside_frame();
But if my iframe is holding an instance of the Cesium map this does not work. Does cesium having something that stops this from happening? Is there a way to override it?
回答1:
Found the answer. You need to change the default security on Cesium with this line:
viewer.infoBox.frame.sandbox = "allow-same-origin allow-top-navigation allow-pointer-lock allow-popups allow-forms allow-scripts";
Then, if you are creating any methods in the Cesium popups you need to add the parent call which allows the button to reference back to the container level.:
onclick="parent.method_outside_frame();"
More details here: https://groups.google.com/forum/#!topic/cesium-dev/Ba_88VXBMvI
来源:https://stackoverflow.com/questions/36094588/call-method-inside-iframe-that-holds-a-cesium-map