<html>
	<head>
	<title>随页面滚动的对联广告</title>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	</head>
	<body>
	<center><h1>随页面滚动的对联广告</h1><hr></center>
	<p> </p><p> </p><p> </p><p> </p>
	<p> </p><p> </p><p> </p><p>
	<script language="JavaScript">
	var delta=0.8;
	var collection;
	var closeB=false;
	function floaters()
	{
	this.items= [];
	this.addItem= function(id,x,y,content)
	{    //向页面写入一个<p>
	document.write('<DIV id='+id);
	document.write(' style="Z-INDEX: 10; POSITION: absolute;width:80px; height:60px;');
	document.write('left:'+(typeof(x)=='string'?eval(x):x));
	document.write(';top:'+(typeof(y)=='string'?eval(y):y)+'">');
	document.write(content+'</DIV>');
	var newItem= {};
	//获取元素属性
	newItem.object= document.getElementById(id);
	newItem.x= x;                    //设置横坐标
	newItem.y= y;                    //设置纵坐标
	this.items[this.items.length]= newItem;
	}
	this.play= function()
	{
	collection= this.items;
	setInterval('play()',30);             //调用函数play()
	}
	}
	function play()
	{
	if(screen.width<=800 || closeB)
	{
	for(var i=0;i<collection.length;i++){              //设置显隐属性
	collection[i].object.style.display= 'none';
	}
	return;
	}
	for(var i=0;i<collection.length;i++)
	{
	var followObj= collection[i].object;
	var followObj_x= (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
	var followObj_y= (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
	//设置左边位置
	if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x))
	{
	var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
	dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
	followObj.style.left=followObj.offsetLeft+dx;
	}
	//设置顶部位置
	if(followObj.offsetTop!=(document.body.scrollTop+followObj_y))
	{
	var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
	dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
	followObj.style.top=followObj.offsetTop+dy;
	}
	followObj.style.display= '';
	}
	}
	function closeBanner()                     //函数:关闭
	{
	closeB=true;
	return;
	}
	var theFloaters= new floaters();
	//添加广告图像
	theFloaters.addItem('followDiv1','document.body.clientWidth-206',80,'<img src="1416433.gif" alt="广告内容二"><br><br><img src=u=345967603,2231543872&fm=0&gp=0.gif onClick="closeBanner();">');
	theFloaters.addItem('followDiv2',6,80,'<img src="u=770972404,4131089670&fm=0&gp=0.gif" alt="广告内容一"><br><br><img src=u=345967603,2231543872&fm=0&gp=0.gif onClick="closeBanner();">');///在这里改为文字或图片!!!!
	theFloaters.play();
	//页面其他内容显示输出
	for(var i=0;i<120;i++)
	{
	document.write("<center>这里是页面内容!</center>");
	}
	</script>
	</p>
	</body>
	</html>
	作者“hwyjavabrain”
	 



 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                