javascript - Adsense 广告 iframe 有 1/3 的时间是空的 html 正文

标签 javascript html adsense

我正在尝试让 Adsense 广告在我的网站上正常工作,但不知何故,它们在某些页面上加载不一致。广告可能有 2/3 的时间正确加载,但有时该空间仍为空白。据我所知,问题不在于没有可用的广告;一个 iframe为广告创建,data-load-complete="true"标签被添加,但不知何故 html body该广告的标记为空:<body marginwidth="0" marginheight="0"></body>

<ins class="adsbygoogle" style="display: block; height: auto !important; min-height: 0px !important;" data-ad-client="ca-pub-..." data-ad-slot="6818818970" data-ad-format="auto" data-full-width-responsive="true" data-adsbygoogle-status="done">
    <ins id="aswift_1_expand" style="display:inline-table;border:none;height:280px;margin:0;padding:0;position:relative;visibility:visible;width:900px;background-color:transparent;">
        <ins id="aswift_1_anchor" style="display: block; border: none; height: 280px; margin: 0px; padding: 0px; position: relative; visibility: visible; width: 900px; background-color: transparent; overflow: visible;">
            <iframe id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;border:0;width:900px;height:280px;" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" width="900" height="280" frameborder="0" src="" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" data-google-container-id="a!1" data-google-query-id="CJf52ubwxewCFQKFgwcdwIoMHw" data-load-complete="true">
                <html class=" yirjomiyii idc0_322">
                    <script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script>
                    <head>
                    <script>window.top.postMessage('{"msg_type":"resize-me","key_value":[{"key":"r_nh","value":"0"},{"key":"qid","value":"COCMyfTkxewCFcaadwodDGMDxA"}],"googMsgType":"sth"}', '*');</script>
                    <script>window.top.postMessage('{"msg_type":"adsense-labs","key_value":[{"key":"settings","value":"[\\\"ca-pub-...\\\",[[1]]]"}],"googMsgType":"sth"}', '*');</script>
                    </head>
                    
                    <body marginwidth="0" marginheight="0"></body>
                </html>
            </iframe>
        </ins>
    </ins>
</ins>
据我了解,通常如果未加载广告,则具有类 adsbygoogle 的元素甚至不应该有 child 。有没有人遇到过这个看似部分加载但带有空 html 正文的广告的问题?有什么想法可能导致这种情况或如何避免这种情况?

最佳答案

这很正常。 AdSense 并不总是返回广告。当 AdSense 没有找到任何广告时 - 它会像您的示例一样返回空 iframe。如果可能,应该折叠空槽(注意 resize-me 消息)。我们不会清理 DOM(例如删除所有 ins 元素和 iframe),因为它不会影响页面的外观。它可能会节省一些内存,但考虑到它是 3 个额外的 DOM 元素,这些节省很少。

关于javascript - Adsense 广告 iframe 有 1/3 的时间是空的 html 正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64465927/

相关文章:

javascript - 如何从 .split 函数中删除单词? (Javascript)

css - 设置 Adsense 自适应广告单元的最大高度

javascript - 通过编辑文件来通过 Node.js 更改 JSON 中的对象值

javascript - 如何在 Symfony2 项目中将 webshim 与 assetic 一起使用?

javascript - 我的 js 代码中缺少的内容我正在丢失)错误

javascript - 如何获取 div 内标签内的单选按钮?

flash - 与长期运行的 Flash/Silverlight 应用程序等效的 Google Adsense

javascript - 是否可以提取 youtube channel /视频页面的 Adsense 发布者 ID?

javascript - 在某些html页面热点禁用onTouchListener

javascript - 正则表达式非将符号后的字符转换为大写