close

Car Insurance Quotes Seattle

<div id="ad-1"> <!-- a second ad goes here -->

Now, place the AdSense JavaScript at the end of the page. Put each ad inside a div with an id so you can easily find it with JavaScript. Put the everything in a div with display set to none so your ads won’t briefly appear at the bottom of the page.

<div style="display:none">  <div id="adsource-0">    <script type="text/javascript"><!--    google_ad_client = "pub-xxxxxxxxxxxxxxxx";    /* Ad Name */    google_ad_slot = "##########";    google_ad_width = 125;    google_ad_height = 125;    //-->    </script>    <script type="text/javascript"    src="    </script>  
<div id="adsource-1"> ...

Finally, use JavaScript to move each ad to its proper place. This script uses document.getElementById to find the ad and the placeholder, then it uses appendChild to move the ad into the placeholder div.

<script type="text/javascript">numAds = 1;for (var i = 0; i < numAds; i++) {    source = document.getElementById("adsource-" + i);    placeholder = document.getElementById("ad-" + i);    placeholder.appendChild(source);}</script>

How well does it work?

Consider this entire site a live tech demo. Refresh the page and watch under the “Advertisements” header of the sidebar. After all of the content is loaded, the ads pop into place.

It breaks my layout!

With this setup, the placeholders initially take up no space, so they expand when the ad gets loaded. If this breaks your layout, you can set the height and width of the placeholder to the dimensions of the ad like this:

<div id="ad-0" style="width: 125px; height: 125px"> <!-- this placeholder takes up space! --> 

Edit (A bit later, still June 4)

Apparently, this is what I get for writing a post about AdSense. See? This is why we can’t have nice things.


auto insurance quotes comparison hawaii     auto insurance quotes and compare


TAGS


CATEGORIES

.