AMP:< amp-iframe>的来源不能等于容器 [英] AMP: Origin of <amp-iframe> must not be equal to container

查看:83
本文介绍了AMP:< amp-iframe>的来源不能等于容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的第一个AMP项目中解决这个问题,

I want to solve this problem in my first AMP project,

这是我遇到的问题:

error.js:58:

error.js:58:

Origin of <amp-iframe> must not be equal to container

这是我的index.html中的amp-iframe代码:

This is my amp-iframe code in my index.html:

<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>

当我导航控制台"选项卡时,这就是我所拥有的:

when I navigate the console tab, this is what I have:

Powered by AMP ⚡ HTML – Version 1462999126709

AMP validation successful.

我曾经使用<amp-iframe>使用外部javascript,即我的custom.js

I used <amp-iframe> to use external javascript, my custom.js

推荐答案

问题是您正在尝试对与AMP具有相同起源的内容进行amp-iframe.出于安全原因,这是被禁止的(主要与同源策略在iframe中使用合成来源的方式有关.)

The problem is that you're trying to amp-iframe content that's on the same origin as the AMP. That's forbidden for security reasons (mostly to do with the way the same-origin policy uses synthetic origins inside iframes).

解决方法是确保从外部来源向AMP提供外部JS.因此,如果您的AMP在example.com上,则应该从SOMEOTHERORIGIN.example.com

The fix is to make sure that external JS is served from a different origin to your AMP. So if your AMPs are on example.com then you should serve the iframed JS from SOMEOTHERORIGIN.example.com

这篇关于AMP:&lt; amp-iframe&gt;的来源不能等于容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆