How to create a float ads which move slowly

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
hoangvu.che
Forum Newbie
Posts: 19
Joined: Thu Mar 22, 2007 9:54 pm

How to create a float ads which move slowly

Post by hoangvu.che »

I have created a float ads which moves along the page scrolling.
However, I can not make it move smoothly as you can see a similar ads in this page

http://www.dantri.com.vn

Moreover, the float ads is not displayed in IE 7.0

Here is my code:

Code: Select all

  <script type="text/javascript" language="JavaScript"><!-- Copyright 2001 William Bontrager
var Type = 'Z';
function StartFloat() {
if(document.all) {
	document.all.AdFloater.style.pixelLeft = document.body.clientWidth - document.all.AdFloater.offsetWidth;
	document.all.AdFloater.style.visibility = 'visible';
	Type = 'A';
	}
else if(document.layers) {
	document.AdFloater.left = window.innerWidth - document.AdFloater.clip.width - 16;
	document.AdFloater.visibility = 'show';
	Type = 'B';
	}
else if(document.getElementById) {
	document.getElementById('AdFloater').style.left = (window.innerWidth - 130) + 'px';
	document.getElementById('AdFloater').style.visibility = 'visible';
	Type = 'C';
	}
if (document.all) { alert('onscroll');window.onscroll = Float; }
else { setInterval('Float()', 100); }
}
function Float() {
if (Type == 'A') { document.all.AdFloater.style.pixelTop = document.body.scrollTop; }
else if (Type == 'B') { document.AdFloater.top = window.pageYOffset; }
else if (Type == 'C') { 	
	document.getElementById('AdFloater').style.top = window.pageYOffset + 'px';
}
} //-->
Besides, I put a

Code: Select all

<span id="AdFloater" style="position: absolute; visibility: hidden; top: 1px;" align="right"><img src=""></span>
tag right before </body> tag

Could you help me with the above prolems?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Jebus! Lose the smooth scroll and just have it stick for gods sake!

Code: Select all

position:fixed;
may be of interest.
Post Reply