If user has some kind of ad blocker installed, ad blocker will of course remove all ads from my website, and it leaves empty spaces where the ads used to be. I would like to use that empty space by putting some other content in it, like links to most important pages of my website, to do that I need to detect if AdSense javascript is loaded.
Methods that I have tried so far:
if (!document.getElementById("google_ads_frame1"))
{
}
and:
if (typeof(window.google_render_ad) == "undefined")
{
}
Both of those seem to fail in certain situation, for example if browser downloads AdSense javascript files a bit slower, it will execute above mentioned code before AdSense code is loaded and I end up hiding ads for users that don't even have ads blocked.
Do you have any suggestions on how could I make sure that my code is run after AdSense? Or some other way of detecting that AdSense scripts are not loaded?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…