javascript - Loading Google adsense after page load -
my website has page loads content using ajax. need append google ads @ content of request conditionally. know google ads doesn't work ajax because makes second request using document.write works before page load complete. thought of hacking document.write , works (atleast in firefox). can please let me know if against google policies.
$.ajax(function(){ ..... success: function(){ document.write = function() { var script = document.createelement('script'); script.type = "text/javascript"; script.src = location.protocol + "//www.google.com/ads/search/module/ads/3.0/xxxx/n/search.js"; document.getelementsbytagname('head')[0].appendchild(script); }; var script = document.createelement('script'); script.type = "text/javascript"; script.src = location.protocol + "//www.google.com/adsense/search/ads.js"; document.getelementsbytagname('head')[0].appendchild(script); }//success end });//ajax end
fyi: strings hard-coded explanation only.
the violation of google terms , conditions has been discussed in different threads regarding topic ( ads refreshing ). refresh div has google ad inside it example has answer throws light on bit vague ( imo ) google policy.
well, apart google has introduced other tag model handling situation of refreshing ads.
so answer problem lies in new google ad tag called gpt - google publisher tag information on gpt can visit introduction google publisher tag. @ sample google publisher tag
Comments
Post a Comment