我试图在示例html中添加谷歌广告感,但它在控制台中显示错误?

时间:2017-05-03 05:45:33

标签: javascript jquery html css3 adsense

<!DOCTYPE html>
<html>
<head>
This is the head of your page.
<title>Example HTML page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

</head>
<body>
This is the body of your page.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- horizontal ad -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-1677523677681098"
     data-ad-slot="1902657162"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
This is the body of your page.
</body>
</html>[enter image description here][1]

它显示ERR:FILE NOT FOUND。 我使用过本地adsgoogle.js,但它没有用。 我已经在下面附上了控制台的截图。

https://i.stack.imgur.com/558XF.png

2 个答案:

答案 0 :(得分:1)

您看到这一点的原因是因为行//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js。这是与协议相关的。

在屏幕截图中,您是从file:///加载的 - 您的计算机上不存在httphttps协议所在的路径。

要解决此问题,请考虑将src更改为https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js或将其指向相对路径(如果您希望加载本地adsbygoogle.js文件。

如果您在本地安装了Python,另一个解决方案是运行本地网络服务器,并通过http而不是file协议查看您的网站。这可以通过打开终端cd到您的桌面,然后运行python -m SimpleHTTPServer,然后在浏览器中访问http://localhost:8000来完成。

答案 1 :(得分:0)

您在Chrome中使用ABP - Adb-blocker extension。这就是阻止广告显示。尝试禁用ABP Extension并刷新(Ctrl + F5)