2017-07-27 71 views
1

实例工作: -AMP iframe是不是AMP灯箱

<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="fixed" sandbox="allow-scripts allow-same-origin allow-popups" frameborder="0" src="https://ampbyexample.com/"></amp-iframe> 
    </div> 
</amp-lightbox> 

<button class="ampstart-btn caps m2" on="tap:my-lightbox" role="button" tabindex="0">Open Iframe in Lightbox</button> 

我也试图操纵的iFrame的75%或600px的从顶部的位置,但它也不能正常工作。

AMP iFrame包含我们想用来获取用户在我们的AMP页面中选择的交付日期的Jquery UI日历。

是否有可能获得并传递AMP iFrame中的值?

回答

2

如果您的iframe显示出现问题,请将占位符图像添加到iframe元素中。这将允许您规避75%/ 600像素的限制。您可以添加一个占位符,就像这样:

<amp-iframe width="350" height="300" layout="fixed" 
       sandbox="allow-scripts allow-same-origin allow-popups" frameborder="0" 
       src="https://ampbyexample.com/"> 
    <amp-img layout="fill" 
      src="https://placekitten.com/g/300/300" 
      placeholder></amp-img> 
    </amp-iframe> 

更新

如果你正试图从放大器的iframe,将数据发送给家长,这将(增加了大约是iframe父共享数据语句)不行。限制在这里解释: https://github.com/ampproject/amphtml/blob/master/spec/amp-iframe-origin-policy.md

+0

感谢这真的很有帮助。 –

相关问题