3rd party ads (adsense) spacing issues in your website

ads are good but can be annoying at times as they usually bring in some extra html or css that might mess with your layout. take google ads for example, it sometimes inject a fix height and width to an ad even if it doesnt pull in any ads.

so the solution is to implement a custom javascript fix to counter the ads styling:

<script type=”text/javascript”>
jQuery(window).load(function() {
googleFrame = jQuery(‘iframe[id^=”google_ads_iframe_”]’);
googleFrame.each( function () {
if (jQuery(this).contents().find(‘body’).html() == ”) {
jQuery(this).attr(‘height’, ‘0’);
if (jQuery(this).css(‘display’) != ‘none’) {

Like it.? Share it:

Comments are closed.