我想在我的第一个AMP项目中解决这个问题,
这是我的问题:
error.js:58:
Origin of <amp-iframe> must not be equal to container
Run Code Online (Sandbox Code Playgroud)
这是我的index.html中的amp-iframe代码:
<amp-iframe
width=100
height=100
layout="nodisplay"
sandbox="allow-same-origin allow-forms allow-scripts"
src="https://www.example.com/scripts/app.js">
</amp-iframe>
Run Code Online (Sandbox Code Playgroud)
当我浏览控制台选项卡时,这就是我所拥有的:
Powered by AMP ? HTML – Version 1462999126709
AMP validation successful.
Run Code Online (Sandbox Code Playgroud)
我曾经<amp-iframe>使用外部javascript,我的custom.js
ade*_*ade 12
问题是你正在尝试与AMP相同的amp-iframe内容.出于安全原因,这是被禁止的(主要与同源政策在iframe中使用合成来源的方式有关).
解决方法是确保外部JS从不同的源服务到您的AMP.因此,如果你的AMP在example.com上,那么你应该从SOMEOTHERORIGIN.example.com提供iframed JS.