homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

AdSense ads in floating layer

 4:40 am on Aug 27, 2003 (gmt 0)

Has anyone tried place the AdSense code within a "floating" layer using DHTML, similar to the navigation menus that float in place as the user scrolls?

This would be great for long pages, so that the ads stay in front of the visitors eyes.

Or would this be in violation of Google's TOS?



 5:04 am on Aug 27, 2003 (gmt 0)

I want to konw this too... have you tried to consult with Google AdSense team?


 7:45 am on Aug 27, 2003 (gmt 0)

Well since that is a standard feature (CSS position:fixed) I can't see how it's wrong. Only that IE doesnT' support it, but shame on them.


RTM Communications

 6:51 pm on Aug 27, 2003 (gmt 0)

We're doing this on one of the client sites - it's primarly a forum-driven community site. Some of the forum threads are very long.

We have the 120x600 AdSense skyscraper in a floating (docked) area that scrolls down with the page. Just installed the Javascript code this morning.

No idea how it will affect CTR (since it is one of several sites on the same AdSense account) but the site is busy, so in theory we should notice a bit of a jump in CTR - if, in fact it is more visually "there" regardless of page scrolling.

As for the TOS - I doubt it is against it.... the AdSense code is 100% stock original, only the surrounding tags that make it float down. I actually got the code, and idea, from another site that was running a floating AdSense skyscraper...



 7:10 pm on Aug 27, 2003 (gmt 0)

Would you mind sharing the code?


 7:28 pm on Aug 27, 2003 (gmt 0)

would love this code too if poss - please sticky mail if need be

RTM Communications

 7:44 pm on Aug 27, 2003 (gmt 0)

OK, here is the code we used. The usual warnings apply; backup your page(s) before applying, ideally test it out on a dummy page. No warranty, may contain peanuts, some assembly required, etc... ;-)

The following should be inserted in the <HEAD> area of your page:

<script language="JavaScript1.2">
var offsetfromedge=10 //offset from window edge when content is "docked". Change if desired.
var dockarray=new Array() //array to cache dockit instances
var dkclear=new Array() //array to cache corresponding clearinterval pointers

function dockit(el, duration){
if (!document.all) return;
this.source=document.all? document.all[el] : document.getElementById(el);
var pointer=eval(dockarray.length-1);
var dynexpress='dkclear['+pointer+']=setInterval("dockornot(dockarray['+pointer+'])",100);';
dynexpress=(this.duration>0)? dynexpress+'setTimeout("clearInterval(dkclear['+pointer+']); dockarray['+pointer+'].source.style.top=0", duration*1000)' : dynexpress;

var totaloffset=parseInt(this.source.offsetTop);
var parentEl=this.source.offsetParent;
while (parentEl!=null){
return totaloffset;

function dockornot(obj){
if (obj.pagetop>obj.elementoffset) //detect upper offset
else if (obj.pagetop+obj.docheight<obj.elementoffset+parseInt(obj.source.height)) //lower offset

function truebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body

if (document.all)


The following demonstrates the insertion of the Google AdSense code - in 120x600 skyscraper form - within a table:

<table width="125px" border="0" id="google_dock" class="dockclass">

<script type="text/javascript"><!--
google_ad_client = "pub-123456789";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_color_border = "000000";
google_color_bg = "000000";
google_color_link = "FF0000";
google_color_url = "666666";
google_color_text = "FFFF00";
<script type="text/javascript"

Note the ID and CLASS parameters in the opening TABLE tag above.

Finally, the following code should be inserted at the bottom of the page, just before the closing </body> tag:

<script language="JavaScript1.2">
var dock0=new dockit("google_dock", 0);

If you're interested in seeing how this works, sticky me, and I will send you the URL of where it is running. If you do set it up, I would like to see it to get an idea of what it looks like on your site.


[edited by: Jenstar at 6:56 pm (utc) on Nov. 13, 2003]
[edit reason] removed AdSense publisher's ID # [/edit]


 10:35 pm on Aug 27, 2003 (gmt 0)

If you want to use just css and not javascript for this, you can use the method found at devnull.tagsoup.com/fixed/vertical.html, which isn't my page, but is where I grabbed the method I'm testing for one of my sites. So far (about 6 hours, so far) I haven't noticed a huge CTR difference, but with the usual end-of-the-month slowdown upon us I'm going to give it until at least the 3rd or 4th for testing.

This method had the added advantage that since I was already using css for all my positioning, all it required of me was to add one extra div around my main non-adsense content and then modify my one external css file.

I tested it this morning in IE/NS and Mozilla on Mac OS9+10, Win 98 to ME and Win NT to XP and it worked fine in everything but IE 4 for Mac OS9, and NS 4 (any OS). In the cases it didn't work (because of lack of proper css support in those REALLY old browsers), the page degraded just fine and displayed ok, just didn't diplay the adsense code in a fixed box.

If you're going to use this method, I think also using custom scrollbar css (only works in IE) to help them blend into the site better looks nicer.


 2:45 am on Aug 28, 2003 (gmt 0)

It will be interesting if this flies with the AdSense team. This could easily be construed as "promoting" the ads; keep in mind that purposely drawing attention to the ads to increase CTR is forbidden.

If I were a betting person I would wager it will be added to the TOS no-no's.


 3:19 am on Aug 28, 2003 (gmt 0)

You could say the same thing about changing the color to a very high contrasting color that attracts the eye? Is that violating Google's rules (given Google lets us change the color ourselves now).


 3:46 am on Aug 28, 2003 (gmt 0)

Personally I loathe those floating panels that jiggle down the screen as I scroll. I am always inclined to get away from a site like that in short order.

They remind me of creepy sales staff, that even after they've asked if you need help - and you say "no thanks, I'm just browsing" - they continue to follow you around the store, ready to pounce.

So to my way of looking at it, putting ads in floating panels would be demoting the google ads, not promoting them.


 3:52 am on Aug 28, 2003 (gmt 0)

I read through the Adsense TOS, Program Policies and FAQ twice to try and make sure I wasn't missing anything that forbid it and couldn't find anything that seemed to apply.

The methods above are basically the same as if you stuck the ads in a navigation frame on the page (which has been fairly widely done, judging by the people who complain about the ads only targeting the frame), but instead of only getting it's keywords from the frame it can target the entire page.

The only relevent part of the Program Policies seems to be "Only one ad unit may be placed on each web page. Ads must not be displayed on any pop-ups, pop-unders, error, registration, or "thank you" pages, or in any email." which certainly doesn't prohibit this.

The incentive part talked about above says "Web pages may not include incentives of any kind for users to click on ads. This includes labeling the ads as sponsors as well as asking users to click on the ads or to please visit the sites." which would be a pretty big stretch to make that cover where on a page you stick the ads being some sort of incentive, otherwise you'd be required to find the lowest CTR place on the page to stick them, lest you be accused of creating an incentive through placement.


 3:56 am on Aug 28, 2003 (gmt 0)

"Personally I loathe those floating panels that jiggle down the screen as I scroll. I am always inclined to get away from a site like that in short order."

Yeah, they look weird. That's one of the reasons I think the CSS method (instead of using javascript) works alot better. Then you get the effect of part of the page (non-adsense) scrolling with a normal scroll bar if it needs to, not the adsense part of the page jumping around "floating" in a jumping panel and possibly covering part of the content, etc...


 1:50 pm on Aug 28, 2003 (gmt 0)

Can someone post an example of the CSS version of this?

I tried slapping a DIV tag around my adsense code and using the "fixed position" thing and it wouldn't work... I thought I was doing it right... I was, according to blooberry.com .. hmm...

RTM Communications

 8:52 pm on Aug 29, 2003 (gmt 0)

Personally I loathe those floating panels that jiggle down the screen as I scroll. I am always inclined to get away from a site like that in short order.

They remind me of creepy sales staff, that even after they've asked if you need help - and you say "no thanks, I'm just browsing" - they continue to follow you around the store, ready to pounce.

Hahahha... well you know what - I sort of agree. I haven't heard any negative feedback about my "creepy sales staff" floating AdSense box on one of our sites. It also doesn't seem to have affected CTR either way. Mind you, our CTR is pretty low since we are running the ads primarily on highly dynamic forum pages.

We'll see...


P.S. I really like the idea of a CSS implementation - but on the right side (as opposed to top or left)... also, since our design (dimensions) are not pixel size fixed, it would have to use some sort of variable space (the 120 rightmost pixels of the page) sort of code.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Google / Google AdSense
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved