Wonder how to rise your ads number of clicks? Many script available out there to make floating google ads. But this one is quite different, this would make your ads more eye-catching with sliding and shaking feature. Plus automatic hide which is actually optional, you can modify it if you just want to put a close button rather than the automatic hide.
This script is based on Dynamic Drive DHTML AdBox with a little feature added.
OK, lets start. Here we go…
1. Save this javascript to your host :
Spoiler :
/******************************************
* DHTML Ad Box (By Matt Gabbert at http://www.nolag.com)
* Visit http://www.dynamicdrive.com/ for full script
* Re-Mix By !CrazyDavinci! - http://crazydavinci.net
* This notice must stay intact for use
******************************************/
Lebar=screen.availWidth;Tinggi=screen.availHeight;
var shakeTime=7000;
var startShow=1000;
var AdTop=parseInt(Tinggi/2-150) // location from top (ads height/2);
var AdLeft=parseInt(Lebar/2-150);// location from left (ads width/2)
var slideStep=15;var slideInternal=10;
var adDiv;var TO = null;var Slide = null;
var ns=(document.layers);var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
var curHeight = 0;var shakePos = 5;
function initAd(){
if(!ns && !ie && !w3) return;
if(ie) adDiv=eval('document.all.sponsorAdDiv.style');
else if(ns) adDiv=eval('document.layers["sponsorAdDiv"]');
else if(w3) adDiv=eval('document.getElementById("sponsorAdDiv").style');
setTimeout("showAd();", startShow);}
function shakeAd(object,speed){
tmpobj = eval(object)
if (shakePos == 5)shakePos = -5;
else shakePos = 5;
tmpobj.left = parseInt(tmpobj.left) + shakePos + calunit;
tmpobj.top = parseInt(tmpobj.top) + shakePos + calunit;
tmpobj = object;sp = speed;TO = setTimeout("shakeAd(tmpobj,sp)",speed);
}
function stopshake(){
clearTimeout(TO);
}
function slideAd(){
var stopSlide = 1;
if(ie){
documentWidth = AdLeft+truebody().scrollLeft-20;
documentHeight = (slideStep>0 && curHeight< =AdTop+truebody().scrollTop-20) ? curHeight:AdTop+truebody().scrollTop;
stopSlide = !(slideStep>0 && curHeight< = AdTop+truebody().scrollTop-20);
}
else if (ns){
documentWidth=AdLeft+window.pageXOffset-20;
documentHeight = (slideStep>0 && curHeight< =AdTop+window.pageYOffset-20) ? curHeight:AdTop+window.pageYOffset-20;
stopSlide = !(slideStep>0 && curHeight< = AdTop+window.pageYOffset-20);
}
else if (w3){
documentWidth=AdLeft+window.pageXOffset-20;
documentHeight = (slideStep>0 && curHeight< = AdTop+window.pageYOffset-20) ? curHeight:AdTop+window.pageYOffset-20;
stopSlide = !(slideStep>0 && curHeight< = AdTop+window.pageYOffset-20);
}
adDiv.left=documentWidth+calunit;
adDiv.top =documentHeight+calunit;
curHeight=curHeight+slideStep;
if(stopSlide){
clearTimeout(Slide);shakeAd(adDiv,75);
setTimeout("stopshake()",shakeTime);
}
else Slide = setTimeout("slideAd()",slideInternal);
}
function showAd(){
slideAd();if (ie||w3) adDiv.visibility="visible"
else adDiv.visibility ="show"window.onscroll = moveAd;
}
function moveAd(){
if (ie){
documentWidth = AdLeft+truebody().scrollLeft-20;
documentHeight =AdTop+truebody().scrollTop-20;
}
else if (ns){
documentWidth=AdLeft+window.pageXOffset-20;
documentHeight=AdTop+window.pageYOffset-20;
}
else if (w3){
documentWidth=AdLeft+window.pageXOffset-20
documentHeight=AdTop+window.pageYOffset-20;
}
adDiv.left=documentWidth+calunit;
adDiv.top =documentHeight+calunit;
}
function closeAd(){
if (ie||w3)adDiv.display="none"
else adDiv.visibility ="hide"
window.onscroll = null;
}
function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function ilang(){
initAd();
setTimeout("closeAd()",19000);
}
if (window.addEventListener) window.addEventListener("load",ilang, false);
else if (window.attachEvent) window.attachEvent("onload",ilang);
else if (document.getElementById) window.onload=ilang
<div id="sponsorAdDiv" style="position:absolute;top:-9999;left:-9999;">
PUT YOUR GOOGLE ADS SCRIPT HERE
</div>
4. Done.
You can adjut the left and top position of the ads by changing the vars : AdTop & AdLeft, you can also use this to tweak any ads, not only for google ads
4 Responses to “Floating, Sliding and Shaking Google Ads”
July 26th, 2009 at 8:27 PM
Owww…Nice…So Nice.
Thanks for this tutorial. Hehehe.
I’ll try it ! Thanks to Joy.
July 27th, 2009 at 9:05 AM
your welcome buddy..
It’s your request, i finally made the post.. xixixi..
sorry for posting so late ramz..
happy hunting for online income
January 9th, 2010 at 1:57 AM
wow wow nice post ^^
March 8th, 2010 at 3:56 PM
thanks for leaving a commnent bro