以下是 给展示的图片加上工具栏特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.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 http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="JS代码,图片特效,JS广告代码,JS特效代码" />
<meta name="description" content="此代码内容为给展示的图片加上工具栏,属于站长常用代码" />
<title>给展示的图片加上工具栏</title>
<style>
img {display:block}
#imgBox {width:500px; }
#imgBox li {list-style-type:none; margin:10px;position:relative; float:left; border:1px solid #999; padding:1px}
.showimg {width:200px; height:150px;}
.toolbar {width:16px; height:16px; position:absolute; display:none; left:10px; top:10px}
.maxImg {bottom:5px; right:5px; position:absolute; display:none; cursor:hand; background-color:transparent; padding:0; border:none}
</style>
</head>
<body>
<ul id="imgBox">
<li><img src="images/xpbz0573.GIF"></li>
<li><img src="images/xpbz0575.GIF"></li>
<li><img src="images/xpbz0578.GIF"></li>
<li><img src="images/xpbz0580.GIF"></li>
<li><img src="images/xpbz0566.GIF"></li>
</ul>
<script type="text/javascript">
var imgBox = document.getElementById("imgBox");
var li = imgBox.getElementsByTagName("li");
for (i=0; j=li[i]; i++){
j.onmouseover = function(){this.getElementsByTagName('div')[0].style.display='block';this.getElementsByTagName('button')[1].style.display='block';}
j.onmouseout = function(){this.getElementsByTagName('div')[0].style.display='none';this.getElementsByTagName('button')[1].style.display='none';}
j.getElementsByTagName("img")[0].className = "showimg";
var toolbars = '<div class="toolbar"><button class="imgtoolbar1" onclick="var img2 = this.parentNode.parentNode.getElementsByTagName(\'img\')[0]; img2.style.filter==\'\'?img2.style.filter=\'Gray()\':img2.style.filter=\'\'"><img src="images/gray.gif" title="黑白反转"></button></div>';
toolbars+= '<button class="maxImg" onclick="window.open(this.parentNode.getElementsByTagName(\'img\')[0].src)"><img src="images/big.gif" title="查看大图" /></button>';
j.innerHTML += toolbars;
}
</script>
</body>
</html>