Forum Moderators: martinibuster
<div id="adsense_area">
// Adsense code here
</div>
// blah blah blah
<script>
var alternate_code = blah blah blah;
var interval = setInterval(function() {
if (document.readyState === 'complete') {
clearInterval(interval);
if (document.getElementById('adsense_area').clientHeight == 0)
document.getElementById('adsense_area').innerHTML = alternate_code;
}
}, 500);
</script>
</body>
</html>
Sorta defeats the purpose of the Ad Balancer altogether, doesn't it?
if (document.getElementById('adsense_area').clientHeight == 0)
if (document.getElementById('adsense_area').clientHeight < 32)
var alternate_code = blah blah blah;
document.addEventListener('DOMContentLoaded', (event) => {
if (document.readyState === 'complete' &&
document.getElementById('adsense_area').clientHeight < 32)
document.getElementById('adsense_area').innerHTML = alternate_code;
}
}
document.addEventListener('DOMContentLoaded', (event) => {
if (document.readyState === 'complete')
alert('yes');
}); var testLoaded = false;
if (document.readyState !== 'loading') {
altFunc();
}
else {
testLoaded = true;
document.addEventListener('DOMContentLoaded', altFunc);
}
function altFunc() {
if (testLoaded) { document.removeEventListener('DOMContentLoaded', altFunc); }
if (document.getElementById('adsense_area').clientHeight < 32)
document.getElementById('adsense_area').innerHTML = alternate_code;
}
Uncaught SyntaxError: Unexpected token %
// at the bottom of the page
var interval = setInterval(function() {
if (document.readyState === 'complete') {
clearInterval(interval);
altFunc();
}
}, 500);
function altFunc() {
var block, blockHeight, m;
// I have a maximum of 6 ads on a page, so I check for block_[0-5]
for (m=0; m < 5; m++) {
block = 'block_' + m;
if (document.getElementById(block))
blockHeight = document.getElementById(block).clientHeight;
// if height is less than 50 then it's safe to assume nothing loaded
if (blockHeight < 50) {
// I have a function named "ajax", so this loads alt.php in "block_0" or whatever
ajax(block, 'alt.php');
}
}
} I have a lot of times where a banner won the bid and is trying to load, but doesn't for some reason. In those cases the height is set by Google