【问题标题】:I m trying to add google ad sense in a sample html but it shows error in the console?我正在尝试在示例 html 中添加 google adsense,但它在控制台中显示错误?
【发布时间】:2017-05-09 20:08:33
【问题描述】:
<!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

【问题讨论】:

标签: javascript jquery html css adsense


【解决方案1】:

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

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

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-10
      • 1970-01-01
      • 2017-12-01
      • 1970-01-01
      • 2022-01-21
      • 2017-04-06
      • 2020-07-06
      相关资源
      最近更新 更多