【问题标题】:Adsense ad iframe has an empty html body 1/3 of the timeAdsense 广告 iframe 有 1/3 的时间是空的 html 正文
【发布时间】:2020-10-22 05:04:51
【问题描述】:

我正在尝试让 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 类的元素甚至不应该有任何子元素。有没有人遇到过这个看似部分加载但带有空 html 正文的广告的问题?有什么想法可能导致这种情况或如何避免这种情况?

【问题讨论】:

    标签: javascript html adsense


    【解决方案1】:

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

    【讨论】:

    • 谢谢。我不知道返回了一个空的 iframe。 In other threads on this site 我的印象是,在这种情况下,直到 adsbygoogle 类的所有元素都是空的。
    猜你喜欢
    • 2013-04-15
    • 1970-01-01
    • 2016-01-09
    • 1970-01-01
    • 1970-01-01
    • 2014-04-30
    • 2016-01-15
    • 2014-09-03
    • 1970-01-01
    相关资源
    最近更新 更多