Ruby 在 Rails - 不同的 jQuery 导致 adblock 消息的开发和生产
Ruby on Rails - different jQuery results in development and production for adblock message
在我的应用程序中,我添加了一些 jQuery 代码以在用户打开 adblock 时显示一条消息。在我的 development ENV 中,我可以看到消息,但是在 production ENV 中使用相同的代码,它 work/do 却不是一回事。
这是我的代码
var canRunAds = true;
function hallo(){
$("#showmsg").html("<p>You are using adblock</p>");
}
if( window.canRunAds === undefined ){
hallo();
}
我什至创建了一个名为 showads.js
的文件,并使用 var canRunAds = true;
将其包含在我的 head
中,但在 production 中它变为 var canRunAds != 0;
原因。
我怎样才能让它工作,还是我做错了什么?
这是我如何让它工作的。
将 showads.js
更改为 ads.js
并在页脚中添加了代码。
$(document).ready(function(){
if( window.canRunAds === undefined ){
$("#showmsg").html("<p>You are using adblock</p>");
}
});
看起来 adblock 没有阻止 showads.js
但 ads.js
在我的应用程序中,我添加了一些 jQuery 代码以在用户打开 adblock 时显示一条消息。在我的 development ENV 中,我可以看到消息,但是在 production ENV 中使用相同的代码,它 work/do 却不是一回事。
这是我的代码
var canRunAds = true;
function hallo(){
$("#showmsg").html("<p>You are using adblock</p>");
}
if( window.canRunAds === undefined ){
hallo();
}
我什至创建了一个名为 showads.js
的文件,并使用 var canRunAds = true;
将其包含在我的 head
中,但在 production 中它变为 var canRunAds != 0;
原因。
我怎样才能让它工作,还是我做错了什么?
这是我如何让它工作的。
将 showads.js
更改为 ads.js
并在页脚中添加了代码。
$(document).ready(function(){
if( window.canRunAds === undefined ){
$("#showmsg").html("<p>You are using adblock</p>");
}
});
看起来 adblock 没有阻止 showads.js
但 ads.js