DoubleClick 广告无法与清单文件配合使用

发布于 2024-11-29 15:02:30 字数 1823 浏览 0 评论 0原文

我正在构建一个使用 Google Doubleclick 广告的 HTML5 应用程序。该应用程序的 99% 是使用 JS 动态构建的,但广告被硬编码到 html 中,如下所示:

 <script type='text/javascript' src='http://partner.googleadservices.com/gampad/google_service.js'></script>
<script type='text/javascript'>
GS_googleAddAdSenseService("ca-pub-3664602748600160");
GS_googleEnableAllServices();
GA_googleAddSlot("ca-pub-3664602748600160", "125x125");
GA_googleAddSlot("ca-pub-3664602748600160", "250x250");
GA_googleAddSlot("ca-pub-3664602748600160", "160x600");
GA_googleAddSlot("ca-pub-3664602748600160", "468x60"); 
GA_googleFetchAds();
</script>

<div id="ads" style="float:right;">

<div id="square" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("250x250");
    </script>
    </div>
</div>

<div id="small_square" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("125x125");
    </script>
    </div>
</div>   
<div id="tall_banner" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("160x600");
    </script>
    </div>
</div>

<div id="half_banner" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("468x60");
    </script>
    </div>
</div>        

然后,这些广告根据需要隐藏/移动,以填充生成的页面上的各个广告位。当我实现清单文件来缓存持久资源时,我收到一条消息,指出它无法加载 http: //partner.googleadservices.com/gampad/google_service.js 文件。知道这一点后,我尝试保存该 js 文件的本地副本并将其包含在清单中,但这导致了有关 GA_googleblahlah 调用未定义的错误,这似乎表明存在某种加载顺序问题。有什么方法可以使该文件免于缓存吗?

I'm building an HTML5 app that uses Google Doubleclick ads. 99% of the app is dynamically built with JS, but the ads are hardcoded into the html like so:

 <script type='text/javascript' src='http://partner.googleadservices.com/gampad/google_service.js'></script>
<script type='text/javascript'>
GS_googleAddAdSenseService("ca-pub-3664602748600160");
GS_googleEnableAllServices();
GA_googleAddSlot("ca-pub-3664602748600160", "125x125");
GA_googleAddSlot("ca-pub-3664602748600160", "250x250");
GA_googleAddSlot("ca-pub-3664602748600160", "160x600");
GA_googleAddSlot("ca-pub-3664602748600160", "468x60"); 
GA_googleFetchAds();
</script>

<div id="ads" style="float:right;">

<div id="square" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("250x250");
    </script>
    </div>
</div>

<div id="small_square" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("125x125");
    </script>
    </div>
</div>   
<div id="tall_banner" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("160x600");
    </script>
    </div>
</div>

<div id="half_banner" style="visibility:hidden">
    <div>
    <script type='text/javascript'>
        GA_googleFillSlot("468x60");
    </script>
    </div>
</div>        

These ads are then hidden/shifted as needed to fill the various ad spots on the generated pages. When i implemented a manifest file to cache persistent assets i get a message that it has failed to load the http://partner.googleadservices.com/gampad/google_service.js file. Knowing this, I tried saving a local copy of that js file and including it in the manifest, but this led to errors regarding the GA_googleblahlah calls being undefined which seems to indicate a load order issue of some sort. Is there some way to exempt this file from cache?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事还在继续 2024-12-06 15:02:30

我找到了解决方案。定义缓存元素后在网络区域使用通配符似乎解决了该问题。我的清单文件现在如下所示:

CACHE MANIFEST
CACHE:
/js/jquery.min.js
/js/jquery.easing.1.3.js
/etc
NETWORK:
*

感谢 Ben Poole 的指点。

I found the solution. Using a wildcard in the network area after defining the cached elements seems to have fixed the issue. My manifest file now looks like this:

CACHE MANIFEST
CACHE:
/js/jquery.min.js
/js/jquery.easing.1.3.js
/etc
NETWORK:
*

Thanks to Ben Poole for the pointers.

很酷又爱笑 2024-12-06 15:02:30

如果您不希望缓存某个文件,请将其添加到清单文件的 NETWORK: 部分。来自深入了解 HTML5

标记为 NETWORK: 的行是“在线白名单”的开头
部分。此部分中的资源永远不会被缓存,也不会被缓存。
离线可用。 (尝试在离线时加载它们将导致
发生错误。)

If you don't want a file to cache you add it to the NETWORK: section of your manifest file. From Dive Into HTML5:

The line marked NETWORK: is the beginning of the “online whitelist”
section. Resources in this section are never cached and are not
available offline. (Attempting to load them while offline will result
in an error.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文