views:

225

answers:

3

I am using a method GA_googleFillSlot from google ad service to load the ads. Which has to be loaded on the right rail of the page in my web site.

As part of speeding up my web site, I want to move the method with related javascripts to the bottom of the page. The javascript method creates a new div with id google_ads_div_<name of ad slot> and ad content.

Since the ad div is located at the bottom of the page, I need to relocate the div to the right place(inside a parent div, right rail div of the site). Here, even though the div and javascript files are being moved to the parent div, iframe body content of the div is missing.

I hae tried the following prototype methods to move the div content to parent div: insert, appendChild, replace

I am not much familiar with the javascript, please advice me if I am doing wrong? Any help is highly appreciated.

A: 

you should use a document onload event to load the ad content. Basically any javascript DOM manipulation you do should always come AFTER the document has loaded.

If you were to use jQuery javascript library you'd use

jQuery(document).ready(function() {
  // code for loading your ad
});

In Prototype JS you'd use

document.loaded
Mark
Thanks Mark for the quick reply. I have tried out the way you mentioned above with the help of prototype js as well as plain javascripts window.onload().In both case, am not sure what is happening, when the control reaches the line for loading ad, the page becomes blank and the status bar shows reading from partner.googleadserice.com and the page hangs for ever.
nkm
+1  A: 

This is the best answer I've seen so far: http://www.google.com/support/forum/p/Google%20Ad%20Manager/thread?tid=7bcfaa482259cc28&amp;hl=en

It's definitely not perfect, as it relies on absolute positioning, not the onload, but it seems that the Google Ad javascript code is incompatible with onload. It's a real pain.

Micah
A: 

Ads generally can't be moved around in the DOM because they use document.write(). If a document has completed loading and a document.write() happens, a new (blank) page will be created and write will be rendered there. This leaves two options short of changing how your ads are delivered: CSS absolute positioning or moving the rest of the content in the DOM and leaving the ad where it is. Both of these are only useful in limited circumstances.

If you are a large enough AdSense advertiser, there may be other options available to you. There are advertising solutions that are only available to trusted Google partners.

cogg