JavaScript控制多张图片循环播放(淡入淡出效果)
2008-12-12 11:41
756 查看
<style>
.imgShow{
font-size: 12px;
background-color: #B0C6CE;
text-align: center;
vertical-align: middle;
display: table-caption;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
position:absolute;
width:400px;
height:300px;
}
.imgHide{
font-size: 12px;
background-color: #B0C6CE;
text-align: center;
vertical-align: middle;
display: table-caption;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
position:absolute;
filter:alpha(opacity=0);
opacity:0.00;
width:400px;
height:300px;
}
</style>
<script>
var hideTime=null;
var hide=100;//过滤镜初始值,IE
var hideFF=1.0;//过滤镜初始值,FF
var show=0;
var showFF=0.00;
var imgShow=1;
var imgSrcArray=new Array("http://p.blog.csdn.net/images/p_blog_csdn_net/lip009/EntryImages/20080726/0001.jpg","http://p.blog.csdn.net/images/p_blog_csdn_net/lip009/EntryImages/20080726/0004.jpg","http://p.blog.csdn.net/images/p_blog_csdn_net/lip009/EntryImages/20080726/0005.jpg");
function hideObject(hideImage,showImage){
try{
hidehide=hide-1;
hideFFhideFF=hideFF-0.01;
showshow=show+1;
showFFshowFF=showFF+0.01;
hideImage.style.filter="alpha(opacity="+hide+")";
hideImage.style.opacity=hideFF+"";/*FF兼容*/
//hideImage.style.-moz-opacity=hideFF+"";
showImage.style.filter="alpha(opacity="+show+")";
showImage.style.opacity=showFF+"";/*FF兼容*/
if(hide<=0){
showImage.style.filter="alpha(opacity=100)";
showImage.style.opacity=1.0;/*FF兼容*/
window.clearInterval(hideTime);
hideImage.style.display="none";
window.setTimeout(changeImage,1000);
}
}catch(e){
window.clearInterval(hideTime);
}
}
function changeImage(){
hide=100;
hideFF=1.0;
show=0;
showFF=0.0;
imgShow++;
if(imgShow>imgSrcArray.length){
imgShow=1;
}
var img1=document.getElementById("img1");
var img2=document.getElementById("img2");
var imageShow,imageHide;
if(img1.style.display=="none"){
img1.className="imgHide";
img2.className="imgShow";
img1.style.display="";
img1.src=imgSrcArray[imgShow-1];
imageShow=img1;
imageHide=img2;
}else{
img2.className="imgHide";
img1.className="imgShow";
img2.style.display="";
img2.src=imgSrcArray[imgShow-1];
imageShow=img2;
imageHide=img1;
}
hideTime=window.setInterval(function(){hideObject(imageHide,imageShow);},20);
}
</script>
<img class="imgShow" id="img1" src="/image/1.jpg">
<img class="imgHide" id="img2" src="/image/2.jpg">
<pre></pre>
http://blog.csdn.net/lip009/archive/2008/07/26/2712344.aspx
.imgShow{
font-size: 12px;
background-color: #B0C6CE;
text-align: center;
vertical-align: middle;
display: table-caption;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
position:absolute;
width:400px;
height:300px;
}
.imgHide{
font-size: 12px;
background-color: #B0C6CE;
text-align: center;
vertical-align: middle;
display: table-caption;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
position:absolute;
filter:alpha(opacity=0);
opacity:0.00;
width:400px;
height:300px;
}
</style>
<script>
var hideTime=null;
var hide=100;//过滤镜初始值,IE
var hideFF=1.0;//过滤镜初始值,FF
var show=0;
var showFF=0.00;
var imgShow=1;
var imgSrcArray=new Array("http://p.blog.csdn.net/images/p_blog_csdn_net/lip009/EntryImages/20080726/0001.jpg","http://p.blog.csdn.net/images/p_blog_csdn_net/lip009/EntryImages/20080726/0004.jpg","http://p.blog.csdn.net/images/p_blog_csdn_net/lip009/EntryImages/20080726/0005.jpg");
function hideObject(hideImage,showImage){
try{
hidehide=hide-1;
hideFFhideFF=hideFF-0.01;
showshow=show+1;
showFFshowFF=showFF+0.01;
hideImage.style.filter="alpha(opacity="+hide+")";
hideImage.style.opacity=hideFF+"";/*FF兼容*/
//hideImage.style.-moz-opacity=hideFF+"";
showImage.style.filter="alpha(opacity="+show+")";
showImage.style.opacity=showFF+"";/*FF兼容*/
if(hide<=0){
showImage.style.filter="alpha(opacity=100)";
showImage.style.opacity=1.0;/*FF兼容*/
window.clearInterval(hideTime);
hideImage.style.display="none";
window.setTimeout(changeImage,1000);
}
}catch(e){
window.clearInterval(hideTime);
}
}
function changeImage(){
hide=100;
hideFF=1.0;
show=0;
showFF=0.0;
imgShow++;
if(imgShow>imgSrcArray.length){
imgShow=1;
}
var img1=document.getElementById("img1");
var img2=document.getElementById("img2");
var imageShow,imageHide;
if(img1.style.display=="none"){
img1.className="imgHide";
img2.className="imgShow";
img1.style.display="";
img1.src=imgSrcArray[imgShow-1];
imageShow=img1;
imageHide=img2;
}else{
img2.className="imgHide";
img1.className="imgShow";
img2.style.display="";
img2.src=imgSrcArray[imgShow-1];
imageShow=img2;
imageHide=img1;
}
hideTime=window.setInterval(function(){hideObject(imageHide,imageShow);},20);
}
</script>
<img class="imgShow" id="img1" src="/image/1.jpg">
<img class="imgHide" id="img2" src="/image/2.jpg">
<pre></pre>
http://blog.csdn.net/lip009/archive/2008/07/26/2712344.aspx
相关文章推荐
- JavaScript控制多张图片循环播放(淡入淡出效果)
- JavaScript代码实现图片延迟加载并淡入淡出显示效果
- JavaScript控制图片左右播放的幻灯片代码
- javascript 图片淡入淡出效果 实例源代码
- php广告图片循环播放 幻灯片效果
- 网页图片循环滚动播放效果
- JavaScript 渐变效果页面图片控制第1/2页
- Javascript实现图片轮播效果(二)图片序列节点的控制实现
- javascript控制图片播放的实现代码
- javascript控制图片播放的实现代码
- javascript实现图片循环渐显播放的代码(图片轮播)
- javascript 控制图片播放代码
- 分享一个自己利用javascript中的window.setInterval()定时器实现页面背景图片变换的特效(同时淡入淡出效果)
- javascript实现图片循环渐显播放的方法
- JavaScript代码实现图片循环滚动效果
- JavaScript图片水平淡入淡出切换效果代码
- javascript实现图片循环渐显播放的方法
- (精)N张图片在网页上循环播放,效果很是不错
- 动态生成Gallery控件组合实现无限循环自动播放广告图片效果总结
- javascript实现图片左右轮换效果(鼠标控制亦可)