amp-consent:未获得同意时解雇盒子高度

时间:2018-05-07 15:09:51

标签: amp-html accelerated-mobile-page

我在使用data-block-on-consent属性时遇到了一些问题,并且一旦用户反对广告和跟踪活动,每个受影响的元素的高度仍然存在,并显示由高度定义的空白空间元素的属性。

<amp-ad .... height=100..> 

问题是:如果没有用户同意,如何摆脱这个空白区域?

1 个答案:

答案 0 :(得分:2)

假设有一个按钮或某个元素被点击以解除同意/广告,则amp-bind应该能够处理将高度更改为零,因为height是一个可绑定属性。这样的东西应该可以工作,更换你的tapped元素的按钮。

<amp-ad height="250" 
       [height]="adHeight[currentHeight]"
       ...>
</amp-ad>
<amp-state id="adHeight">
<script type="application/json">
{
  "noHeight": 0,
  "fullHeight": 250
}
</script>
</amp-state>

<button on="tap:AMP.setState({currentHeight: 'noHeight'})">Hide Ad</button>