length is not a function, it is a property
var adblock = function(adspace) {
if ($(adspace).length <= 1 || $(adspace).height() == 0) {
window.location.replace("../disable-adblock");
}
}
Вопрос
So I have three functions here, they're messing about with each other.
Take a look:
$(document).ready(function() {
var update = function(element, url) {
if ($(element).length) {
$(element).effect("highlight", {color: "#f7f7f7"}, 2000); $(element).load(url);
}
}
var adblock = function(adspace) {
if ($(adspace).height() == 0 || $(adspace).length() <= 1) {
window.location.replace("../disable-adblock");
}
}
adblock(".coinurl");
var refresh_div = setInterval(function() {
update(".total-plays", "../logs/total-plays.txt");
}, 30000);
$.ajaxSetup({ cache: false });
}); //doc
Now the problem is that for some reason the OR (||
) operator in the second function disables my setInterval
function. But, when I delete || $(adspace).length() <= 1
everything works fine - accept now the adblock function doesn't work with Chrome!
What's going on here? Have I executed the OR statement incorrectly, or is this script in the wrong order?
Thanks
Решение
length is not a function, it is a property
var adblock = function(adspace) {
if ($(adspace).length <= 1 || $(adspace).height() == 0) {
window.location.replace("../disable-adblock");
}
}