当前位置:首页 > 代码 > 正文

banner图片切换代码(css实现banner轮换图)

admin 发布:2022-12-19 08:26 105


今天给各位分享banner图片切换代码的知识,其中也会对css实现banner轮换图进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

banner图片JS切换过渡效果怎么做??

你去百度搜 js调用代码 有很多的 刚刚你那站我看了 没发现里面有js过渡效果 你搜下 有些站专门 有这类的!~

求简单的图片切换代码

第一种:

把如下代码加入body区域中

body onclick=Clicked()

SCRIPT

!--

transeffect = 0;

theeffects = new Array(24);

theeffects[0] = “盒状收缩“;

theeffects[1] = “盒状向外“;

theeffects[2] = “圆形收缩“;

theeffects[3] = “圆形向内“;

theeffects[4] = “从下向上“;

theeffects[5] = “从上向下“;

theeffects[6] = “从左向右“;

theeffects[7] = “从右向左“;

theeffects[8] = “百页窗形向右“;

theeffects[9] = “百页窗形向下“;

theeffects[10] = “棋盘形交叉向右“;

theeffects[11] = “棋盘形交叉向下“;

theeffects[12] = “随意溶解形“;

theeffects[13] = “左右向内“;

theeffects[14] = “左右向外“;

theeffects[15] = “上下向内“;

theeffects[16] = “上下向外“;

theeffects[17] = “条纹状向左下“;

theeffects[18] = “条纹状向左上“;

theeffects[19] = “条纹状向右下“;

theeffects[20] = “条纹状向右上“;

theeffects[21] = “溶解水平状“;

theeffects[22] = “溶解上下状“;

theeffects[23] = “随着溶解“;

current_image = “image1“;

function Clicked() {

var the_image, the_other;

text2.style.visiblity=“hidden“;

if (image1.style.visibility==“inherit“) {

the_image = image2;

the_other = image1;

}

else {

the_image = image1;

the_other = image2;

}

the_other.style.visibility=“hidden“;

the_image.filters.item(0).Apply();

the_image.filters.item(0).Transition = transeffect;

the_image.filters.item(0).Play(2.0);

the_image.style.visibility=“inherit“;

text2.innerText=theeffects[transeffect];

transeffect++;

if (transeffect == 24)

transeffect = 0;

text2.style.visibility=“visible“;

}

//--

/SCRIPT

DIV id=image

DIV id=text1/DIVIMG id=image1

src=“Upfiles/200422684962.gif“

style=“FILTER: revealTrans(Duration=3.0,Transition=1); VISIBILITY: hidden“ IMG id=image2 src=“Upfiles/200422684962.gif“

style=“FILTER: revealTrans(Duration=3.0,Transition=1); VISIBILITY: hidden“ /DIV

DIV id=text2/DIV

第二步:把body中的内容改为:

body bgcolor=“#fef4d9“ onclick=Clicked()

over feboy

第二种:

第一步、把下面这段代码插入到页面的head与/head之间:

script language=javascript

isns = navigator.appName == "Netscape";

function ztstr(id,picurl,linkurl)

{

this.id=id

this.picurl=picurl

this.linkurl=linkurl

}

zhuanti=new Array()

imgcount=1;

frequency=10*1000;//30秒

//在这里修改图片的路径和链接

zhuanti[1]=new ztstr('1','','')

zhuanti[2]=new ztstr('2','','')

zhuanti[3]=new ztstr('3','','')

zhuanti[4]=new ztstr('4','','')

imgcount=zhuanti.length-1

for(i=1;i=imgcount;i++)

{

eval_r("img"+i+"=new Image()")

eval_r("img"+i+".src=zhuanti["+i+"].picurl")

}

nn=1

var rand1 = 0;

var useRand = 0;

function swapPic() {

var imgnum = zhuanti.length - 1;

do {

var randnum = Math.random();

rand1 = Math.round((imgnum - 1) * randnum) + 1;

} while (rand1 == useRand);

useRand = rand1;

// alert(useRand);

nn=useRand;

change_img();

}

function change_img()

{

eval_r('document.pic.src=img'+nn+'.src');

nn++;

if(nnimgcount) nn=1

if(!isns)

{

pic.filters.item(0).apply()

pic.style.visibility='visible'

pic.filters.item(0).play()

setTimeout("pic.style.visibility='hidden'",frequency);

}

else

document.pic.visibility='visible'

tt=setTimeout('change_img()',frequency)

}

function pictarget()

{

tt=nn-1

if(tt1) tt=imgcount

cururl=zhuanti[tt].linkurl

window.open(cururl);

}

function ini()

{

if(!isns)

{

spacewidth=Math.round((divmask.offsetWidth-770)/2)

dmwidth=770+spacewidth

dmheight=divmask.offsetHeight

totalstep=50

timeout=50

dmstepw=Math.round(770/totalstep)

dmsteph=Math.round(dmheight/totalstep)

setTimeout('hidimg()',3000)

}

else swapPic()

}

function hidimg()

{

dmwidth-=dmstepw

dmheight-=dmsteph

eval_r('divmask.style.clip="rect(0,'+dmwidth+','+dmheight+',0)"')

hdrun=setTimeout('hidimg()',timeout)

if(dmwidth=spacewidthdmheight=0)

{

divmask.style.visibility='hidden'

clearTimeout(hdrun)

swapPic()

}

}

/script

第二步、调用定义好的javascript函数,在body里加上以下代码:

body onload=swapPic()

第三步、在页面中插入图片和链接:

a href=javascript :void(null) onclick='javascript :pictarget();return false;'img src="" width=468 height=60 border=0 name=pic style="visibility:hidden;filter:revealtrans(duration=2.0,transition=12)"/a

好,到这里就大功告成了。另外,试试改变transition的数值,可以得到不同的转换效果哟~~

高分悬赏支持淘宝网页特效的图片切换效果代码

P /P

P align=center /P

TABLE id=table8 borderColor=#bdb76b cellSpacing=0 cellPadding=0 width=533 align=center border=3

TBODY

TR

TD

SCRIPT language=JavaScript

!--

var bannerAD=new Array();

var bannerADlink=new Array();

var adNum=0;

bannerAD[0]="图片地址";

bannerAD[1]="图片地址";

bannerAD[2]="图片地址";

bannerAD[3]="图片地址";

bannerAD[4]="图片地址";

bannerAD[5]="图片地址";

bannerAD[6]="图片地址";

bannerAD[7]="";preloadedimages=new Array();

for (i=1;ibannerAD.length;i++){

preloadedimages[i]=new Image();

preloadedimages[i].src=bannerAD[i];

}

function setTransition(){

if (document.all){

bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);

bannerADrotator.filters.revealTrans.apply();

}

}

function playTransition(){

if (document.all)

bannerADrotator.filters.revealTrans.play()

}

function nextAd(){

if(adNumbannerAD.length-1)adNum++ ;

else adNum=0;

setTransition();

document.images.bannerADrotator.src=bannerAD[adNum];

playTransition();

theTimer=setTimeout("nextAd()", 5000);

}

function displayStatusMsg() {

status=bannerADlink[adNum];

document.returnValue = true;

}

//--

/SCRIPT

P align=centerIMG style="FILTER: revealTrans(duration=2,transition=20)" height=400 src="" width=533 border=0 name=bannerADrotator/P

SCRIPT language=JavaScriptnextAd()/SCRIPT

/TD/TR/TBODY/TABLE

P /P

P /P

跪求这段jquery banner切换代码的解释

//将当前显示的BANNER图片的索引值设置为0,也就是默认是第一个图片的序号

var t = n = 0, count;

$(document).ready(function(){

//定义获取四张BANNER图

count=$("#banner_list a").length; 

//设置默认显示第一张BANNER图,其他的隐藏

$("#banner_list a:not(:first-child)").hide(); 、

//设置默认标题为第一张图标的alt信息

$("#banner_info").html($("#banner_list a:first-child").find("img").attr('alt'));

//点击默认的标题,链接到第一张BANNER图的a链接地址

$("#banner_info").click(function(){

window.open($("#banner_list a:first-child").attr('href'), "_blank")

});

//这里为切换数字按钮点击事件

$("#banner li").click(function() {

//获取Li元素内的值,即1,2,3,4

var i = $(this).text() - 1;

//将i的值赋值给新变量n(也就是当前显示图片的索引值序号)

n = i;

//如果被点击的数字按钮的值大于等于BANNER的总数则退出当前语句

if (i = count) return;

//设置标题为当前点击按钮对应的BANNER图片的alt信息

$("#banner_info").html($("#banner_list a").eq(i).find("img").attr('alt'));

//删除标题绑定的事件并重新设置标题点击后 打开点击按钮对应的BANNER图片的a链接

$("#banner_info").unbind().click(function(){window.open($("#banner_list a").eq(i).attr('href'), "_blank")})

//将所有的BANNER图淡入隐藏 当前点击按钮对应的BANNER图片淡入显示

$("#banner_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);

//将容器#banner的背景设置为空

document.getElementById("banner").style.background="";

//将当前点击按钮的样式设置为高亮样式on

$(this).toggleClass("on");

//清除其它点击按钮的高亮样式

$(this).siblings().removeAttr("class");

});

//设置默认的定时器  每4s执行一次showauto函数

t = setInterval("showAuto()", 4000);

//容器#banner鼠标移入后 清清除定时器 (也就是鼠标移动到BANNER上面停止切换),移开则继续切换

$("#banner").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);});

})

//定义自动切换的函数

function showAuto()

{

//如果当前切换的图片索引值大于所有图片的数量 

//也就是当切换到最后一张图片再继续切换的时候 则将当前图片索引设置为0(第一张)

//否则则将当前图片的索引值+1

n = n =(count - 1) ? 0 : ++n;

//重新触发当前BANNER的click事件

$("#banner li").eq(n).trigger('click');

}

关于banner图片切换代码和css实现banner轮换图的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/5227.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载