效果一: |
<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head profile="http://www.w3.org/2000/08/w3c-synd/#">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="oern ,On Error Resume Next" />
<meta name="description" content="Private Site" />
<title>slide</title>
<style type="text/css">
html,body{
width:100%;
height:100%;
margin:0px;
border:0px;
text-align:center;
}
div{
margin:auto;
overflow:hidden;
}
</style>
</head>
<body>
<script type="text/javascript">
function tag(obj){
return document.getElementsByTagName(obj)[0];
}
window.οnlοad=function(){
setTimeout("slideUp();",3000);
}
function slideUp(){
if(tag("div").offsetHeight>0){
if(tag("div").offsetHeight>10){
tag("div").style.height=tag("div").offsetHeight-10+"px"
setTimeout("slideUp();",20);
}else{
tag("div").style.display="none";
tag("img").src="http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/a.jpg";
tag("div").style.display="block";
slideDown();
}
}
}
function slideDown(){
if(tag("div").offsetHeight<80){
if(tag("div").offsetHeight<70){
tag("div").style.height=tag("div").offsetHeight+10+"px";
setTimeout("slideDown();",20);
}else{
tag("div").style.height="80px";
}
}
}
</script>
<div><img src="http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/b.jpg"></div>
</body>
</html>
效果二:
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<style>
html,body{margin:0;font-size:12px}img{border:none}p{border-top:5px solid#660000;padding:40px;background:#999900;height:1500px;margin:0px}
</style>
<script>
var showAD = {
curve: function(t, b, c, d, s) {
if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
return c / 2 * ((t -= 2) * t * t + 2) + b
},
fx: function(from, to, playTime, onEnd) {
var Me = this,
who = this.adWrap,
position = 0,
changeVal = to - from,
curve = this.curve;
playTime = playTime / 10;
who.style.overflow = 'hidden';
function _run() {
if (position++<playTime) {
who.style.height = Math.max(1, Math.abs(Math.ceil(curve(position, from, changeVal, playTime)))) + "px";
setTimeout(_run, 10)
} else {
onEnd && onEnd.call(Me, to)
}
};
_run()
},
init: function(info) {
var Me = this,
loadImg = new Image;
loadImg.src = info.endImgURL;
window.οnlοad=function() {
Me.endImgURL = info.endImgURL;
Me.img = document.getElementById(info.imgID);
Me.adWrap = document.getElementById(info.adWrapID);
var max = Me.img.height;
setTimeout(function() {
Me.fx(max, 0, 500,
function(x) {
this.img.src = this.endImgURL;
this.curve = function(t, b, c, d) {
if ((t /= d) < (1 / 2.75)) {
return c * (7.5625 * t * t) + b
} else if (t < (2 / 2.75)) {
return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b
} else if (t < (2.5 / 2.75)) {
return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b
} else {
return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b
}
};
this.fx(0, this.img.height,600)
})
},
info.timeout || 1000)
};
}
};
showAD.init({
adWrapID: 'ad_box_2009_04',
imgID: 'adImg',
endImgURL: 'http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/a.jpg'
});
</script>
</head>
<body>
<div id="ad_box_2009_04" style="background:BF0008">
<img src="http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/b.jpg" id="adImg" />
</div>
</body>
</html>
三、jquery版效果
<html><head><script type="text/javascript" src="http://www.websjy.com/JS/jquery/jquery.min.js"></script>
<script>
function slide()
{
$("#top1").slideUp(1000,function(){$("#top2").slideDown(1000);});
}
setTimeout("slide()",4000);
</script>
</head><body>
<div style="width:100%;background:#BF0008;text-align:center;" id="top1">
<img src="http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/b.jpg" />
</div>
<div style="width:100%;background:#BF0008;text-align:center;display:none;" id="top2">
<img src="http://c1.neweggimages.com.cn/NeweggPic2/Marketing/200906/hot/a.jpg" border="0" alt="新蛋6月疯狂特价" />
</div></body></html>