2017-07-27 69 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

感謝這真的很有幫助。 –

相關問題