最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】gitbook的Adsense插件报错:Failed to load resource the server responded with a status of 403

gitbook crifan 10006浏览 0评论

折腾:

【已解决】Gitbook页面底部加google adsense广告

期间,看到gitbook的Adsense的js代码中加的log了:

但是看到报错:

adsbygoogle.js:1 [Violation] Avoid using document.write(). https://developers.google.com/web/updates/2016/08/removing-document-write

和:

Failed to load resource: the server responded with a status of 403 ()
20:42:43.253 ads:1 Failed to load resource: the server responded with a status of 403 ()

https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-6626240105039250&output=html&h=250&slotname=6956288491&adk=2235353981&adf=1151504946&w=289&fwrn=4&fwrnh=100&lmt=1561725755&rafmt=1&guci=2.2.0.0.2.2.0.0&format=289×250&url=http%3A%2F%2Flocalhost%3A4000%2F&flash=0&fwr=0&resp_fmts=3&wgl=1&adsid=AGt39rRvyFVUrLLx2IurRMr_eAwc36US1OVlY7av5AJwaSLWOu6gqjVp-0PcMZKskrkQcO6x_SjSRL7nmrbNXiM&dt=1561725761825&bpp=92&bdt=1864&fdt=1115&idt=1116&shv=r20190624&cbv=r20190131&saldr=aa&abxe=1&correlator=6686999351709&frm=20&pv=2&ga_vid=451359626.1547129509&ga_sid=1561725763&ga_hid=117342603&ga_fc=0&iag=0&icsg=618749967204350&dssz=27&mdo=0&mso=0&u_tz=480&u_his=17&u_java=0&u_h=800&u_w=1280&u_ah=777&u_aw=1253&u_cd=24&u_nplug=3&u_nmime=6&adx=315&ady=1802&biw=649&bih=694&scr_x=0&scr_y=0&eid=21060853&oid=3&rx=0&eae=0&fc=912&brdim=6%2C26%2C6%2C26%2C1253%2C23%2C1247%2C774%2C649%2C694&vis=1&rsz=%7C%7CapeEbr%7C&abl=CA&pfx=0&fu=144&bc=31&ifi=1&uci=1.yp656m3wfr00&fsb=1&xpc=llm8l6iRaH&p=http%3A//localhost%3A4000&dtd=1162

pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

广告单元近期更新 – AdSense帮助

Inside AdSense: Looking back, looking forward…

如何为广告单元生成同步广告代码 – AdSense帮助

异步:

<script async src="//pagead2.googlesyndication.com/
pagead/js/adsbygoogle.js"></script>
<!-- leaderboard -->
<ins class="adsbygoogle"
    style="display:inline-block;width:728px;height:90px"
    data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
    data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

同步:

<script type="text/javascript">
    google_ad_client = "ca-pub-xxxxxxxxxxxxxxxx";
    google_ad_slot = "1234567890";
    google_ad_width = 728;
    google_ad_height = 90;
</script>
<!-- leaderboard -->
<script type="text/javascript"
src="//pagead2.googlesyndication.com/
pagead/show_ads.js">
</script>

调试log输出:

参考之前的:

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- gitbook_bottom -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-6626240105039250"
     data-ad-slot="6956288491"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

去改为代码,尽量输出和这里一样

用代码:

// adScript.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
adScript.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';

输出:

也是403了。

但是至少页面是也元素了:

继续调试看看

https://developers.google.com/web/updates/2016/08/removing-document-write

Intervening against document.write()  |  Web  |  Google Developers

Where to place the ad code in your HTML (Auto ads) – AdSense Help

How do you use multiple adsense units on one page? – Stack Overflow

和此处代码很类似

https://googleads.g.doubleclick.net/pagead/ads

出错:

Failed to load resource: the server responded with a status of 403 ()

Failed to load resource: the server responded with a status of 403 (Forbidden) 解决办法 – 付杰博客

Failed to load resource: the server responded with a status of 403 (Forbidden) | WordPress.org

google ads Failed to load resource: the server responded with a status of 403 ()

Ads Not Displaying for Adsense Auto Ads | WordPress.org

Google Ads Not Showing – Failed to load resource: the server responded with a status of 403 (Forbidden) – AdSense Help

[FIXED] Adsense Ad Code – 403 (Forbidden) Error 2019

AdSense errors and warnings explained – Advanced Ads

https://stackoverflow.com/questions/49442413/adsense-ads-giving-error-failed-to-load-resource-the-server-responded-with-a-s

Add your website to Adsense account: It is already checked.

貌似需要添加本地localhost的域名到adsense中?

先不加,还是去试试,把代码上传到服务器上去试试结果。

结果还真是:

上传最新包含google adsense的html到book.crifan.com中(符合adsense中配置的crifan.com

然后此处就没有报错了:

【总结】

此处google Adsense报错:

Failed to load resource: the server responded with a status of 403 ()

原因:

当前调试所属域名没有加到adsense后台配置的域名中

  • 当前调试所属域名:localhost

  • 只是mac本地浏览器调试而已

  • adsense后台:crifan.com

  • 解决办法:

    • 方法1:无需后台修改设置,只是把本地调试的html,上传到crifan.com服务器中即可

    • 本来就打算把 gitbook_demo 的html上传到

  •  -》 然后就可以了,没有报403错了

  • 方法2:修改adsense后台配置

    • 暂时没去操作

    • 去加,也不知道,是否是需要加 localhost

    转载请注明:在路上 » 【已解决】gitbook的Adsense插件报错:Failed to load resource the server responded with a status of 403

    发表我的评论
    取消评论

    表情

    Hi,您需要填写昵称和邮箱!

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址
    82 queries in 0.267 seconds, using 22.10MB memory