报错信息如下
Unsafe JavaScript attempt to initiate navigation for frame with URL ‘http://xxxx’ from frame with URL ‘http://yyyy’. The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor has it received a user gesture

在iframe加上这个代码之后 sandbox="allow-scripts allow-top-navigation allow-same-origin"
sandbox包含的属性及作用:

allow-forms :允许进行提交表单;

allow-scripts :运行执行脚本;

allow-same-origin: 允许同域请求,比如ajax,storage;

allow-top-navigation: 允许iframe能够主导window.top进行页面跳转;

allow-popups: 允许iframe中弹出新窗口,比如,window.open,target=”_blank”;

allow-pointer-lock: 在iframe中可以锁定鼠标,主要和鼠标锁定有关。
Logo

前往低代码交流专区

更多推荐