足球游戏_中国足彩网¥体育资讯$

分析javascript纵向的相册效果
来源:易贤网 阅读:723 次 日期:2014-08-15 16:52:05
温馨提示:易贤网小编为您整理了“分析javascript纵向的相册效果”,方便广大网友查阅!

本代码来自于懒人图库,本站只是对其代码进行分析并解释,并标注了源代码的来源,本次是对纵向的相册效果进行分析.

注明:源文件来源于懒人图库(便于代码简洁,去除了部分懒人的ad)

<!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=gbk" />

<title>纵向的JS相册效果</title>

<style>

body {background:#000000;margin:20px 0;font:12px Verdana, Arial, Tahoma;text-align:center;vertical-align:middle;color:#FFFFFF}

img {border:none}

.txt_1 {font:bold 24px Verdana, Tahoma;color:#fff}

img.thumb_img {cursor:pointer;display:block;margin-bottom:10px}

img#main_img {cursor:pointer;display:block;}

#gotop {cursor:pointer;display:block;}

#gobottom {cursor:pointer;display:block;}

#showArea {height:355px;margin:10px;overflow:hidden}

.info {color:#666;font:normal 9px Verdana;margin-top:20px}

.info a:link, .info a:visited {color:#666;text-decoration:none}

.info a:hover {color:#fff;text-decoration:none}

</style>

</head>

<body>

<table width="760" border="0" align="center" cellpadding="0" cellspacing="5">

<tr>

<td height="75" colspan="2" align="left" class="txt_1">纵向的JS相册效果</td><!--<网站制作学习网Foasp.cn>-->

</tr>

<tr>

<td width="640" align="center"><img src="images/03.jpg" URL width="640" height="400" border="0" id="main_img" rel="images/03.jpg" link="URL" /><!--这是展示整个大图--></td>

<td width="110" align="center" valign="top">

<img src="images/gotop.gif" width="100" height="14" id="gotop" /><!--上边的按钮-->

<div id="showArea">

 <img src="images/01.jpg"  width="80" height="50" border="0" class="thumb_img" rel="images/01.jpg" link="URL" />

 ......省略n个图片

 <img src="images/02.jpg"  width="80" height="50" border="0" class="thumb_img" rel="images/02.jpg" link="URL" /><!--设置rel后图片可以有link的连接,点击直接跳转-->

 

</div>

<img src="images/gobottom.gif" width="100" height="14" id="gobottom" /><!--下边的按钮--></td>

</tr>

</table>

</body>

</html>

<script language="javascript" type="text/javascript">

function $(e) {return document.getElementById(e);}//定义获取通过对象

document.getElementsByClassName = function(cl) {//定义document的通过ClassName来获得对象数组

var retnode = [];//定义空数组

var myclass = new RegExp(cl);//通过正则上面传来的cl值来判断对象

var elem = this.getElementsByTagName('*');

for (var i = 0; i < elem.length; i++) {

 var classes = elem[i].className;//如果classname符合正则则添加到定义的空数组

 if (myclass.test(classes)) retnode.push(elem[i]);

}

return retnode;//最后返回数组

}

var MyMar;

var speed = 1; //速度,越大越慢

var spec = 1; //每次滚动的间距, 越大滚动越快

var ipath = 'images/'; //图片路径

var thumbs = document.getElementsByClassName('thumb_img');//获取以"thumb_img"的数组

for (var i=0; i<thumbs.length; i++) {

thumbs[i].onmouseover = function () {$('main_img').src=this.rel; $('main_img').link=this.link;};//循环对对象进行附加事件

thumbs[i].onclick = function () {location = this.link}

}

$('main_img').onclick = function () {window.open(this.link);}//对中间的大图进行附加事件

$('gotop').onmouseover = function() {this.src = ipath + 'gotop2.gif'; MyMar=setInterval(gotop,speed);}

$('gotop').onmouseout = function() {this.src = ipath + 'gotop.gif'; clearInterval(MyMar);}

$('gobottom').onmouseover = function() {this.src = ipath + 'gobottom2.gif'; MyMar=setInterval(gobottom,speed);}

$('gobottom').onmouseout = function() {this.src = ipath + 'gobottom.gif'; clearInterval(MyMar);}

function gotop() {$('showArea').scrollTop-=spec;}//设定鼠标移动到上下按钮时,图片的整体滚动<网站制作学习网Foasp.cn>

function gobottom() {$('showArea').scrollTop+=spec;}

</script>

中国足彩网信息请查看IT技术专栏

中国足彩网信息请查看脚本栏目
易贤网手机网站地址:分析javascript纵向的相册效果
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
关于我们 | 联系我们 | 人才招聘 | 网站声明 | 网站帮助 | 非正式的简要咨询 | 简要咨询须知 | 加入群交流 | 手机站点 | 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 足球游戏_中国足彩网¥体育资讯$ 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:hfpxwx
咨询QQ:526150442(9:00—18:00)版权所有:易贤网
云南网警报警专用图标