gpt4 book ai didi

在 Rails 应用程序中使用外部脚本时出现 Javascript 空错误

转载 作者:行者123 更新时间:2023-12-04 01:57:02 26 4
gpt4 key购买 nike

我正在使用来自广告服务提供商的横幅广告,类似于 google adsense。
他们网站的说明清楚而简单地表明我们需要做的就是将以下代码复制到我们网页的正文中

<!-- Begin Hsoub Ads Ad Place code -->
<script type="text/javascript"><!--
hsoub_adplace = [my account id];
hsoub_adplace_size = '728x90';
//--></script>
<script src="http://ads2.hsoub.com/show.js" type="text/javascript"></script>
<!-- End Hsoub Ads Ad Place code -->

我已复制并粘贴到我的 rails 应用程序中,在 View 文件的正文中,但横幅未显示,我可以看到 javascript 错误(使用浏览器检查源)

TypeError: document.getElementById(...) is null



ps :在旧浏览器上会显示横幅,但不会在最新版本的浏览器上显示。

ps2 : hsoub 的支持多次确认,他们方面没有问题(他们的代码很好,可以在数千个网站上运行,我的帐户是事件的,没有问题)。这一定是我的代码的问题..我在想 Rails 处理 javascript 的方式......
你能帮我解决这个错误并显示横幅吗?

ps3 : 我正在使用 rails 6.0.1和 turbolinks 5.2.0
您可以在线查看错误/源代码 https://tafqit.com/

最佳答案

问题是由 CloudFlare cdn 服务的 Rocket Loader 功能引起的

Rocket Loader improves paint times for pages that include Javascript. Visitors will have a better experience by seeing content load faster and speed is also a factor in some search rankings.

Rocket Loader improves paint times by asynchronously loading your Javascripts, including third party scripts, so that they do not block rendering the content of your pages.



我禁用了它,横幅现在出现了。

关于在 Rails 应用程序中使用外部脚本时出现 Javascript 空错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60031678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com