Call method inside iframe that holds a Cesium map

冷暖自知 提交于 2019-12-24 05:49:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!