使用 Trust Pilot 自定义脚本时,我无法获得 AMP 验证,并出现错误:Custom JavaScript is not allowed. AMP 不允许自定义脚本。
我需要添加<script type="text/javascript" src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js" defer></script>信任试点审查工作。如何让这个自定义脚本与 AMP 一起使用?谢谢
更新:
我找到了一种解决方法(好吧,如果它最终有效),但是,我遇到了另一个问题。我将 Trustpilot 脚本和小部件放在单独的文件中,然后放在我的 AMP 页面上,我会用amp-iframe它来将它放在页面上。AMP 将进行验证,但 Iframe 未呈现以下错误消息:Origin of <amp-iframe> must not be equal to container。我在这里尝试了一些解决方案,但到目前为止没有任何效果。
<amp-iframe width="275" height="380"
resizable
sandbox="allow-scripts allow-same-origin"
layout="responsive"
frameborder="0"
src="/trustpilot">
<div overflow tabindex=0 role=button aria-label="Read more">Read more!</div>
</amp-iframe>