# Adsense广告在主题导航或目录页面上未重新加载，frame-src拒绝CSP错误和未捕获的异常错误 EmberJS

**URL:** <https://meta.discourse.org/t/adsense-ads-not-reloading-on-topic-navigations-or-on-toc-pages-frame-src-refused-csp-errors-and-uncaught-exception-errors-emberjs/171422>\
**Category:** Support\
**Created:** [2020年十一月26日 14:32 UTC](https://meta.discourse.org/t/adsense-ads-not-reloading-on-topic-navigations-or-on-toc-pages-frame-src-refused-csp-errors-and-uncaught-exception-errors-emberjs/171422 "2020-11-26T14:32:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Faizan\_Zahid](https://avatars.discourse-cdn.com/v4/letter/f/b9bd4f/32.png) [@Faizan\_Zahid](https://meta.discourse.org/u/Faizan_Zahid)\
**Post date:** [2020年十一月27日 10:32 UTC](https://meta.discourse.org/t/adsense-ads-not-reloading-on-topic-navigations-or-on-toc-pages-frame-src-refused-csp-errors-and-uncaught-exception-errors-emberjs/171422/3 "2020-11-27T10:32:20Z")

</div>

感谢 @simon 的迅速回复。

按照您的建议，我已关闭 Cloudflare、Brotli，并关闭了所有针对 CSS、JS 和 HTML 的压缩功能，同时也关闭了 Rocket Loader。

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/a/2a0961aa411ba1543ec4e6df3fb597a928ecd7da.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/a/7a9b1582b3cf9f6d1051d5cc730f6fb47a2f6fbc.png)

我还清除了 CF 缓存，并等待了 30 分钟以测试效果，但在访问我的主页 [https://howtodiscuss.com](https://howtodiscuss.com) 时，JS 控制台仍然出现奇怪的错误：

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/e/ae74816e9c27d70f0b75753b7fb59847b28f0f79.png)

在导航到话题页面 [Catholic rosary - How To Discuss](https://howtodiscuss.com/t/catholic-rosary/18598) 时也是如此：

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/5/e5a3b91b33abe0b4496006a42dbb83f69de7ce94.png)

您可以在 Chrome 无痕模式下打开我的网站并尝试导航到几个页面/话题，即可复现这些错误。

另外，您是否知道为什么我固定在话题时间线/话题导航右侧的 AdSense 广告，只有在完全刷新页面（使用浏览器刷新图标）或首次访问网站时才会显示，而在后续页面加载时该功能无法触发广告？它似乎无法检测到话题页面已更改。

它每次都进入这个 else 代码块。我的自定义 Discourse 插件逻辑中是否存在检测用户导航到话题页面的 bug？我希望每次导航时都能显示并重新加载新的 AdSense 广告，但它却进入了 else 分支。代码认为 ID #friends 已存在，但除非我进行完整的硬刷新，否则它从未重新加载。 **超时已清除，放弃了。**

> [@Faizan\_Zahid](#):
>
> ```plaintext
> function loadFriends() {
> 
> if (!document.getElementById('friends')) {
> //var timer;
> friends_retries++;
> if (friends_retries < 10) {
> //console.log('timeout rescheduled, try ' + friends_retries);
> window.setTimeout(loadFriends, 100);
> } else {
> clearTimeout(friends_timeout);
> // window.clearTimeout(loadFriends);
> 
> console.log('timeout cleared, gave up');
> // loadFriends();
> }
> } else {
> 
> var bHTML = ' <!-- Topic side bar timeline HTD --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7087907313091932" data-ad-slot="5067761793" data-ad-format="auto" data-full-width-responsive="true"></ins>';
> 
> // var bHTML = '<img src="https://via.placeholder.com/300x250?text=300x250+MPU" alt="Girl in a jacket">';
> 
> $("#friends").html(bHTML);
> 
> }
> }
> 
> ```

请帮帮我。您可以自行浏览我的网站话题，会在 JS 控制台中发现所有问题。我在 JS 控制台中还收到了这个警告，Google 的展示广告用户始终无法点击。

```
弃用通知：一次性移除所有事件监听器已被弃用，请逐个移除每个监听器。

```

> **[How To Refurbish Your Staircase?](https://howtodiscuss.com/t/how-to-refurbish-your-staircase/30612)**
>
> Every homeowner wants their home to make a statement. Stunning home décor can fetch you amazing compliments from your guests. Be it your furniture, walls, paintings, decorative items, floors, or flooring accessories, all are essential to your...

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/9/1921b50fa75bb68d4c8c91e23eb55c89e8d5e554.png)

我已经按照您的建议关闭了 CF 的速度优化功能，包括 CSS/JS/HTML 压缩、Rocket Loader 和 Brotli。现在还有什么问题吗？会不会是某个 Discourse 插件导致的？这是我当前启用的插件：

 ![image](https://global.discourse-cdn.com/meta/original/3X/7/d/7de98e6f4adae7016b6923e9a2784be376c5f9fd.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/e/f/efd80225c3b771d1d5341d200fdf56b4d894ce1e.png)

我的 SSL 设置为严格模式，这会是问题所在吗？

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/0/c08d3d0d35a2f62b7733e4c379bed01efa07243c.png)

我还刚刚重新构建了一次，以防构建后变更生效……但错误依旧，刚刚又测试了一次 ☹

---

_[View the full topic](https://meta.discourse.org/t/adsense-ads-not-reloading-on-topic-navigations-or-on-toc-pages-frame-src-refused-csp-errors-and-uncaught-exception-errors-emberjs/171422)._
