【问题标题】:Close button with an interstitial out of page ad带有页外插页式广告的关闭按钮
【发布时间】:2016-07-29 03:56:34
【问题描述】:

我正在尝试向 dfp 中的页外插页式广告添加关闭按钮,但无法使其正常工作。我尝试按照谷歌提供的说明进行操作,但没有成功。

这是我的代码

<script>
$(document).ready( function() {
    $(window.parent.document).find('body').css({
        "Background-Attachment": "fixed",
        "Background-Image": "url('[%Image%]')",
        "Background-Position": "top center",
        "Background-Repeat": "no-repeat",
    });

    $(window.parent.document).find('body')
        .after('<a href="%%CLICK_URL_UNESC%%[%ClickthroughURL%]" target="_blank">' + 
            '<img src="%%VIEW_URL_UNESC%%[%Image%]" style="display:block;position:fixed;left:0;top:0;width:100%;height:100%;cursor:pointer" />/a>');


});
</script>
<script>
function closeHandler() {
  Enabler.reportManualClose(); 
  Enabler.close();
}
</script>

<style>
#close-btn {
  position: absolute;
  width: 20px;
  height: 18px;
  top: 0px;
  left: 278px;
  cursor: pointer;
  z-index:220;
  background-image: url('[%Closebtn%]');
  background-repeat: no-repeat;
}
</style>

<div id="close-btn"></div>

感谢任何帮助将不胜感激

【问题讨论】:

    标签: javascript jquery ads interstitial google-dfp


    【解决方案1】:

    尝试调用closeHandler() 函数;)

    function closeHandler() {
      Enabler.reportManualClose(); 
      Enabler.close();
    }
    closeHandler();
    

    【讨论】:

      【解决方案2】:

      我想通了,所以这里是解决方案。代码有点改变,但我正在实现我想要的结果。

      <html>
       <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <title>Test 1</title>
         <style type="text/css">
          .center-me {
              position: absolute;
              visibility: visible;
              width: 100%;
              height: auto;
              margin: 0;
              z-index: 10;
              top: 50px;
              left: 0;
          }
      
          .center-me img {
               width: 100%;
               height: auto;
         }
      
          #close-btn {
              position: absolute;
              width: 45px;
              height: 45px;
              top: 70px;
              right: 15px;
              cursor: pointer;
              z-index:220;
              background-image: url('[%CloseBtn%]');
              background-repeat: no-repeat;
          }
        </style>
      
        <script>
        $(document).ready(function(){
          $("#close-btn").click(function(){
              $(".ad-wrapper").fadeOut(500);
          });
      
      });
        </script>
       </head>
      
       <body style="margin: 0px;">
          <div class="ad-wrapper">
              <div id="close-btn"></div>
              <a href="%%CLICK_URL_UNESC%%[%ClickthroughURL%]">
                <div class="center-me">
                  <img src="%%VIEW_URL_UNESC%%[%ImageFile%]"></img>
                </div>
              </a>
          </div>
       </body>
      
      </html>
      

      【讨论】:

      • out of page 订单项您创建了哪个尺寸的广告单元?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多