【问题标题】:Amp- iframe in amp Lightbox or amp-accordionamp-iframe in amp Lightbox 或 amp-accordion
【发布时间】:2017-04-07 10:34:01
【问题描述】:

我需要在 amp-lightbox、amp-accordion 或其他 amp-tag 上插入一个外部应用程序。应用程序插入到外部 html 中,因为该代码与 amp-html 代码不兼容。 这个问题的解决方案是什么? iframe 在其他 amp- 中无法正常工作,当我将 iframe 插入 amp- 时,如果我在外部插入代码,页面会显示加载项目符号但不加载内容。 p>

当用户单击特定区域或按钮时启动此应用程序,因为第一次必须为用户隐藏 iframe。

谢谢你

例子:

<!doctype html>
<html ⚡>
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <script async custom-element="amp-lightbox" src="https://cdn.ampproject.org/v0/amp-lightbox-0.1.js"></script>
  <script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
  <link rel="canonical" href="https://ampbyexample.com/components/amp-lightbox/">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
  <style amp-custom>
.lightbox {
  background: rgba(0,0,0,0.8);
  width: 100%;
  height: 100%;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox h1 {
  color: white;
}
 </style>
 </head>
 <body>
<amp-lightbox id="my-lightbox" layout="nodisplay">
  <div class="lightbox" on="tap:my-lightbox.close" role="button" tabindex="0">
  <amp-iframe width="350" height="300" layout="responsive" sandbox="allow-scripts allow-same-origin allow-popups" frameborder="0" src="https://www.xxxxxxxxx.com"></amp-iframe>
  </div>
</amp-lightbox>
<button class="ampstart-btn caps m2" on="tap:my-lightbox" role="button" tabindex="0">
Open lightbox
</button>
</body>
</html>

面积足够应用

【问题讨论】:

  • 你的 iframe 是否加载了 https:// ?
  • 您留下的空间是否正确?如果您提供您的代码示例将会很有帮助,这样我们就不必想象可能会出现什么问题。
  • @lovntola,是的,iframe 和加载的页面(页面应用程序)是 https 页面。
  • @JayGray 示例代码在帖子中,受版权保护,我无法发布 iframe 的真实网址。
  • 好的,我想我看到了问题所在。 iframe 必须与页面顶部保持最小距离。它不能位于页面顶部。但是有一个系统的方法来解决这个要求。我需要查看我的笔记/示例以找到代码。找到后会发回这里。

标签: amp-html


【解决方案1】:

<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>

不见了。见here

【讨论】:

  • 是的,正确,我忘记在帖子中复制这一行,但这不是问题。我要更正邮政编码。
  • 您可以尝试使用 layout="fixed" 而不是响应式的 iframe。我将其用作显示有关折叠的广告的工作方法。
猜你喜欢
  • 2022-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多