2016-04-08 90 views
0

AMP(加速移動頁面)頁面出現問題。當AMP中沒有返回廣告時如何摺疊空白空間

問題:

我在我的AMP中爲廣告設置了Ad EXchange。 如何在AdEX沒有廣告投放時摺疊空格。你能給我一個演示代碼嗎?

我已閱讀Github上的文檔有關window.context.noContentAvailable,但我依然困惑,我應該調用此函數(window.context.noContentAvailable),我應該在哪裏調用window.context.requestResize(寬,高)倒塌的廣告位置時沒有廣告返回。

<!doctype html> 
<html ⚡> 

<head> 
    <meta charset="utf-8"> 
    <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> 
    <script async src="https://cdn.ampproject.org/v0.js"></script> 
</head> 
<body style = "background-color: green;"> 

    <amp-ad width="300" 
     height="200" 
     type="doubleclick" 
     data-slot="/4119129/doesnt-exist" 
     style= "background-color:lightgrey;"> 
    <div placeholder> 
     <!-- <iframe src ="amphtml/3p/frame.max.html"> --> 
     <div> 
      sdsd 
      <script type="text/javascript"> 
       window.parent.context.onResizeSuccess(function (requestedHeight) { 
        console.log('success'); 
        // body... 
       }) 
       window.parent.context.onResizeDenied(function(requestedHeight){ 
        console.log('failed'); 
       }) 
       window.parent.context.requestedResize(3,3); 
      </script> 

     </div> 

    <!-- </iframe> --> 
    </div> 
    </amp-ad> 

    <amp-ad width="300" 
     height="200" 
     type="doubleclick" 
     data-slot="/4119129/doesnt-exist" 
        style= "background-color:yellow;"> 
    <div fallback> 
    <div> 
      <script type="text/javascript"> 
       window.parent.context.onResizeSuccess(function (requestedHeight) { 
        console.log('success'); 
        // body... 
       }) 
       window.parent.context.onResizeDenied(function(requestedHeight){ 
        console.log('failed'); 
       }) 
       window.parent.context.requestedResize(3,3); 
      </script> 
    </div> 
    </div> 
    </amp-ad> 

    </body> 
</html> 

回答

0

當沒有任何內容可顯示時,廣告可以要求隱藏。 AMP只會在不中斷用戶的情況下執行此請求。

我知道doubleclick當前正在發送這些請求,但我不知道其他廣告網絡。如有疑問,請聯繫他們的支持。