1.伸缩后还会有一小BANNER广告
---------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>滑幅广告</title>
</head>
<body>
<center>
<script type="text/javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 330;
this.minHeigth=nMinHth || 2.5;
this.state=sState || "down" ;
var obj = document.getElementById(id);
if(intervalId != null)window.clearInterval(intervalId);
function openBox(){
var h = obj.offsetHeight;
obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"px";
if(obj.offsetHeight>this.maxHeigth){
window.clearInterval(intervalId);
intervalId=window.setInterval(closeBox,this.stayTime);
}
if (obj.offsetHeight<this.minHeigth){
window.clearInterval(intervalId);
obj.style.display="none";
}
}
function closeBox(){
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
}
intervalId = window.setInterval(openBox,30);
}
</script>
<div id="MyMoveAd" style="background:#ff0000;height:12px;overflow:hidden;">
<a href="http:" target="_blank"><img src="http:/jscss/demoimg/200903/982331.gif" border="0" /></a>
</div>
<script type="text/javascript">
<!--
slideAd('MyMoveAd',5);
-->
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="jueban" style="background:red;display: ">
<tr><td height=""><a href="http://codefans.net" target="_blank">
<img src="http:/jscss/demoimg/200903/98230.gif" border="0"></a></td></tr></table>
</center>
</body>
</html>
------------------------------------------------------------------------------------------------------------
2.伸缩后没有广告
----------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>163的JS滑屏广告</title>
<script type="text/javascript" language="javascript">
var time = 500;
var h = 0;
function addCount()
{
if(time>0)
{
time--;
h = h+5;
}
else
{
return;
}
if(h>260) //高度
{
return;
}
document.getElementById("ads").style.display = "";
document.getElementById("ads").style.height = h+"px";
setTimeout("addCount()",30);
}
window.onload = function showAds()
{
addCount();
setTimeout("noneAds()",4000); //停留时间自己适当调整
}
</script>
<script type="text/javascript" language="javascript">
var T = 260;
var N = 260; //高度
function noneAds()
{
if(T>0)
{
T--;
N = N-5;
}
else
{
return;
}
if(N<0)
{
document.getElementById("ads").style.display = "none";
return;
}
document.getElementById("ads").style.height = N+"px";
setTimeout("noneAds()",30);
}
</script>
<!--
body,td,th {
font-size: 12px;
color: #999999;
line-height:20px}
.STYLE1 {
font-size: 24px;
font-weight: bold;
color: #FF0000;
}
.STYLE2 {
font-size: 16px;
font-weight: bold;
color: #3333CC;
}
-->
</style>
</head>
<body>
<div id="ads" style="margin:auto; display:none; width:900px; top:0px; height:0px; border:solid 1px #000; background-color:#fafafa; overflow:hidden; text-align:center;">
<td width="900" height="280"><a href="http:"><img src="/jscss/demoimg/site.gif" border="0"></a></td>
</div>
<div style="margin:auto; width:900px; height:200px; border:solid 1px #000; background-color:#fafafa; text-align:center;">
<div align="left"><br>
<span class="STYLE1">这里是你的主页内容</span><br>
<span class="STYLE2">源码爱好者欢迎您!</span><br>
源码爱好者(CoreFans.net)提供各类编程源码、书籍教程、JavaScript/CSS特效代码以及常用软件下载等,做有质量的学习型×××站。
</div>
</div>
</body>
</html>
---------------------------------------------------------------------------------------------------------------------------------
另一种方式
---------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Generator" content="NO" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<title>滑门广告</title>
<script type="text/javascript" language="javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth)
{
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 330;
this.minHeigth=nMinHth || 2.5;
this.state=sState || "down" ;
var obj = document.getElementById(id);
if(intervalId != null)window.clearInterval(intervalId);
function openBox()
{
var h = obj.offsetHeight;
obj.style.height = ((this.state == "down") ? (h + 1) : (h - 1))+"px";
if(obj.offsetHeight>this.maxHeigth)
{
window.clearInterval(intervalId);
intervalId=window.setInterval(closeBox,this.stayTime);
}
if (obj.offsetHeight<this.minHeigth)
{
window.clearInterval(intervalId);
obj.style.display="none";
}
}
function closeBox()
{
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
}
intervalId = window.setInterval(openBox,15);
}
</script>
</head>
<body>
<div id="MyMoveAd" style="background:#ff0000;height:12px;overflow:hidden;">
<a href="alixixi.com" target="_blank"><img src="http://www.alixixi.com/UploadPic/2009-3/2009313104412586.gif" border="0" /></a>
</div>
<script type="text/javascript" language="javascript">
<!--
slideAd('MyMoveAd',1);
-->
</script>
网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容网页内容
</body>
</html>
转载于:https://blog.51cto.com/ylj798/1061881