views:

371

answers:

3

Hello,

I have problem with displaying adsense ads in ie7

google adsense adds an iframe to display ads with id google_ads_frame1 with position:absolute the problem is this absolute position makes the ad stay there even if the page size changes (in ajax)

so how can i force it to have position:relative, i tried wrapping it in div and applied every possible property like positions, display, wrapping the whole content in a table, floats, zoom, height & width.

i also tried adding a css below the adsense

    <!--[if IE7 ]>
    <style type="text/css">
    #google_ads_frame1 {
       position:relative;
    }
    </style>
    <![endif]-->

can anybody please help me, this thing has made me crazy...

A: 

you should be able to wrap the iframe with a div set with position:relative. are the elements on the page that change size with ajax set with position:absolute or floated as this may cause issues too.

Josh

Josh
i wrapped the adsense in a div and positioned it relative but still it doesnt work.
Shishant
+1  A: 

the ads got unpositioned only when the page resized so everytime a function that cause change in size of the page i added one more javascript to it.

var googleAds = document.getElementById('googleAds'); 
googleAds.style.paddingTop= '1px';
googleAds.style.paddingTop= '0';

it you have better solution please let me know

Shishant
A: 

I've had the same problem and I 'fixed' this by removing a 'background-color' on a wrapping div. Don't ask me why, this has to be the weirdest IE bug ever :)

The wrapping div encompasses almost everything on the page and is fairly unrelated to the table cell that contained the AdSense banner, I have absolutely no idea why this background-color had any effect on the positioning of the banner.

I found this 'solution' by just stripping the page bit by bit. At one point almost all HTML was gone but the problem still persisted. I the removed the CSS file after which the banner behaved normally. Then started stripping the full CSS until I found the line that (seems to) have caused the problem.

Making a proper test case of this is still somewhere on my list but haven't come around to doing that. Also pretty unsure that this is a generic solution. Main advise for now: If you see this problem, remove all CSS and see if that fixes the problem, if it does figure out what part of the CSS seems to be responsible and get rid of that :)

Bart van Bragt