图片超链接直接用A标签不行,请教高手,JS里怎么加代码加在哪儿,使五张轮播图片加上超链接?没分了 20
<scripttype="text/javascript">window.onload=function(){varoBox=document.getElementByI...
<script type="text/javascript">
window.onload = function ()
{
var oBox = document.getElementById("picbox");
var aUl = document.getElementsByTagName("ul");
var aImg = aUl[0].getElementsByTagName("li");
var aNum = aUl[1].getElementsByTagName("li");
var timer = play = null;
var i = index = 0;
//切换按钮
for (i = 0; i < aNum.length; i++)
{
aNum[i].index = i;
aNum[i].onmouseover = function ()
{
show(this.index)
}
}
//鼠标划过关闭定时器
oBox.onmouseover = function ()
{
clearInterval(play)
};
//鼠标离开启动自动播放
oBox.onmouseout = function ()
{
autoPlay()
};
//自动播放函数
function autoPlay ()
{
play = setInterval(function () {
index++;
index >= aImg.length && (index = 0);
show(index);
},5000);
}
autoPlay();//应用
//图片切换, 淡入淡出效果
function show (a)
{
index = a;
var alpha = 0;
for (i = 0; i < aNum.length; i++)aNum[i].className = "";
aNum[index].className = "current";
clearInterval(timer);
for (i = 0; i < aImg.length; i++)
{
aImg[i].style.opacity = 0;
aImg[i].style.filter = "alpha(opacity=0)";
}
timer = setInterval(function () {
alpha += 2;
alpha > 100 && (alpha =100);
aImg[index].style.opacity = alpha / 100;
aImg[index].style.filter = "alpha(opacity = " + alpha + ")";
alpha == 100 && clearInterval(timer)
},20);
}
};
</script>
<div style="clear:both; margin-top:10px; height:200px; text-align:center;">
<div id="picbox">
<ul class="piclist">
<li class="current">
<img src="/images/1.jpg" width="920" height="200" />
</li>
<li><img src="/images/2.jpg" width="920" height="200" /></li>
<li><img src="/images/3.jpg" width="920" height="200" /></li>
<li><img src="/images/4.jpg" height="200" /></li>
<li><img src="/images/5.jpg" width="920" height="200" /></li>
</ul>
<ul class="count">
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div> 展开
window.onload = function ()
{
var oBox = document.getElementById("picbox");
var aUl = document.getElementsByTagName("ul");
var aImg = aUl[0].getElementsByTagName("li");
var aNum = aUl[1].getElementsByTagName("li");
var timer = play = null;
var i = index = 0;
//切换按钮
for (i = 0; i < aNum.length; i++)
{
aNum[i].index = i;
aNum[i].onmouseover = function ()
{
show(this.index)
}
}
//鼠标划过关闭定时器
oBox.onmouseover = function ()
{
clearInterval(play)
};
//鼠标离开启动自动播放
oBox.onmouseout = function ()
{
autoPlay()
};
//自动播放函数
function autoPlay ()
{
play = setInterval(function () {
index++;
index >= aImg.length && (index = 0);
show(index);
},5000);
}
autoPlay();//应用
//图片切换, 淡入淡出效果
function show (a)
{
index = a;
var alpha = 0;
for (i = 0; i < aNum.length; i++)aNum[i].className = "";
aNum[index].className = "current";
clearInterval(timer);
for (i = 0; i < aImg.length; i++)
{
aImg[i].style.opacity = 0;
aImg[i].style.filter = "alpha(opacity=0)";
}
timer = setInterval(function () {
alpha += 2;
alpha > 100 && (alpha =100);
aImg[index].style.opacity = alpha / 100;
aImg[index].style.filter = "alpha(opacity = " + alpha + ")";
alpha == 100 && clearInterval(timer)
},20);
}
};
</script>
<div style="clear:both; margin-top:10px; height:200px; text-align:center;">
<div id="picbox">
<ul class="piclist">
<li class="current">
<img src="/images/1.jpg" width="920" height="200" />
</li>
<li><img src="/images/2.jpg" width="920" height="200" /></li>
<li><img src="/images/3.jpg" width="920" height="200" /></li>
<li><img src="/images/4.jpg" height="200" /></li>
<li><img src="/images/5.jpg" width="920" height="200" /></li>
</ul>
<ul class="count">
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div> 展开
3个回答
展开全部
把这段替换到对应的地方,然后把 #改成你要链接的地方即可
<ul class="piclist">
<li class="current">
<a href=#><img src="/images/1.jpg" width="920" height="200" /></a>
</li>
<li><a href=#><img src="/images/2.jpg" width="920" height="200" /></a>
</li>
<li><a href=#><img src="/images/3.jpg" width="920" height="200" /></a>
</li>
<li><a href=#><img src="/images/4.jpg" height="200" /></a>
</li>
<li><a href=#><img src="/images/5.jpg" width="920" height="200" /></a>
</li>
</ul>
<ul class="piclist">
<li class="current">
<a href=#><img src="/images/1.jpg" width="920" height="200" /></a>
</li>
<li><a href=#><img src="/images/2.jpg" width="920" height="200" /></a>
</li>
<li><a href=#><img src="/images/3.jpg" width="920" height="200" /></a>
</li>
<li><a href=#><img src="/images/4.jpg" height="200" /></a>
</li>
<li><a href=#><img src="/images/5.jpg" width="920" height="200" /></a>
</li>
</ul>
追问
这种链接不行,你可测试一下
展开全部
楼主,这个是我写的图片切换脚本,你可以参考下的
追问
能在我的这个代码上加吗,因为我这个出来的效果还挺好的,就是欠链接了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
img标签外面加超链接啊!<a href=""><img src=""></a>
追问
试过这个方法了,用A标签不起作用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询