在 Safari 中执行这段代码时
iframe.contentDocument || iframe.contentWindow.document
我得到一个错误
Sandbox access violation: Blocked a frame at "My url" from accessing a frame at "null". The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
iframe 是这样形成的:
'<iframe name="'+name+'" id="'+name+'" src="'+src+'" sandbox="allow-same-origin">'
在调试器中,我可以获得具有给定值的属性 iframe.sanbox
我做错了什么?
最佳答案
浏览器会根据网站的偏好自动阻止网站加载。您尝试加载的网站必须设置:
X-Frame-Options: DENY
X-Frame-Options: SAMEORIGIN
来自 this answer .
关于iframe - 如何修复 ‘The frame being accessed is sandboxed and lacks the "允许同源“标志”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54560333/