折腾:
【已解决】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 ()
pagead2.googlesyndication.com/pagead/js/adsbygoogle.js
Inside AdSense: Looking back, looking forward…
异步:
<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
[FIXED] Adsense Ad Code – 403 (Forbidden) Error 2019
AdSense errors and warnings explained – Advanced Ads
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