代码驿站移动版
频道导航
HTML/Xhtml
CSS
JavaScript
HTML5
PHP教程
ASP.NET
正则表达式
AJAX
ThinkPHP
Yii
MySQL
MariaDB
Oracle
MongoDB
Redis
DedeCMS
PHPCMS
帝国CMS
WordPress
Discuz
其它CMS
Zend Studio
Sublime
Notepad
Dreamweaver
Windows
Linux
Nginx
Apache
IIS
CentOS
Ubuntu
Debian
网站优化
工具资源
PHP源码
ASP.NET源码
其它源码
图标素材
按钮素材
字体素材
DedeCMS模板
帝国CMS模板
PHPCMS模板
WordPress模板
Discuz!模板
单页模板
开发软件下载
服务器软件下载
广告投放
联系我们
版权申明
软件编程
网页前端
移动开发
数据库
服务器
脚本语言
PHP代码
JAVA代码
Python代码
Android代码
当前位置:
主页
>
网页前端
>
JavaScript代码
>
多图展示点击切换效果模拟的flash效果,点小图放大显示,再点恢复默认。
时间:2020-11-04 11:14:56 | 栏目:
JavaScript代码
| 点击:次
多图展示点击切换效果模拟的flash效果,点小图放大显示,再点恢复默认。
<base href='http://demo.rexsong.com/200507/image_onclick_switch/'><!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" xml:lang="zh" lang="zh-cn"> <head> <title>类似于Flash制作的一个图片展示效果</title> <meta name="Author" content="http://www.webjx.com"> <meta http-equiv="imagetoolbar" content="no"> <style type="text/css"> html,body {cursor:crosshair;margin:0; padding:0; position:absolute; overflow:hidden; background:#222; left:0; top:0; width:100%; height:100%;zIndex:-2;} </style> <script type="text/javascript"><!-- // ==================================================== window.onerror = new Function("return true"); screen.bufferDepth = 16; document.onselectstart = function () { return false; } //////////////////////////// var NX = 3; var NY = 3; var SP = 20; var DELAY = 96; //////////////////////////// var object = new Array(); var nI = 0; var run = false; var xrun = 0; var dR = 1; var iW = 0; var iH = 0; var oH = 0; var oW = 0; function CObj(N,y,x){ this.obj = document.createElement("span"); this.obj.onclick = new Function("object["+N+"].GE1()"); this.obj.onmousedown = new Function("return false;"); this.obj.style.cursor = "pointer"; this.obj.style.position = "absolute"; this.img = document.createElement("img"); this.img.style.position = "absolute"; this.img.src = IMGSRC[N%nI].src; this.obj.appendChild(this.img); IMGBOX.appendChild(this.obj); this.object = new Array(); this.x = x; this.y = y; this.N = N; this.W = 0; this.H = 0; this.L = 0; this.T = 0; function CImg(Parent,y,x){ this.Parent = Parent; this.obj = document.createElement("span"); this.obj.style.position="absolute"; this.obj.style.overflow="hidden"; this.obj.style.cursor = "pointer"; this.img = document.createElement("img"); this.img.style.position = "absolute"; this.img.src = IMGSRC[N%nI].src; this.obj.appendChild(this.img); this.Parent.obj.appendChild(this.obj); this.N = Parent.N; this.x = x; this.y = y; this.W = 0; this.H = 0; this.L = 0; this.T = 0; this.dx = 0; this.dy = 0; this.px = 0; this.py = 0; this.dw = 0; this.dh = 0; this.pw = 0; this.ph = 0; this.ipx = 0; this.ipy = 0; this.idx = 0; this.idy = 0; this.GE2 = function (){ with(this){ px -= dx * dR; py -= dy * dR; pw += dw * dR; ph += dh * dR; ipx -= idx * dR; ipy -= idy * dR; with(obj.style){ left = Math.round(px); top = Math.round(py); width = Math.round(pw)+1; height = Math.round(ph)+1; if(dR==-1)if(pw<=W+1)obj.style.visibility="hidden"; } with(img.style){ left = Math.round(ipx-oW); top = Math.round(ipy-oH); } if(++xrun>=NX*NY*SP){ xrun=0; run=false; if(dR==-1)Parent.obj.style.zIndex = 0; dR = -dR; } } } this.GE1 = function (N1,N2){ with(this){ if(dR==1){ px = L; py = T; dx = ((Parent.L + L) - (x * Parent.W)) / SP; dy = ((Parent.T + T) - (y * Parent.H)) / SP; pw = W; ph = H; dw = (Parent.W - W) / SP; dh = (Parent.H - H) / SP; ipx = -L; ipy = -T; idx = ((x * Parent.W) - L) / SP; idy = ((y * Parent.H) - T) / SP; } obj.style.visibility="visible"; if(img.height>document.body.offsetHeight)oH=(img.height-document.body.offsetHeight)/2; else oH = 0; if(img.width>document.body.offsetWidth/2)oW=(img.width-(document.body.offsetWidth/2))/2; else oW = 0; for(i=0;i<SP;i++) setTimeout("object["+N1+"].object["+N2+"].GE2()",16*i); } } this.DOOT = function (){ with(this){ W = Parent.W / NX; H = Parent.H / NY; L = x * W; T = y * H; } } } var k = 0; for(var i=0;i<NY;i++) for(var j=0;j<NX;j++) this.object[k++] = new CImg(this,i,j); this.GE1 = function (){ with(this){ if(!run){ TXTBOX.innerHTML = "<div style='margin:2%'>"+TXTSRC[N%nI].innerHTML+"</div>"; run = true; obj.style.zIndex = 1; for(var i=0;i<NX*NY;i++) setTimeout("object["+N+"].object["+i+"].GE1("+N+","+i+")",i*DELAY); } } } this.DOOT = function (){ with(this){ if(img.width<iW)iW=img.width; if(img.height<iH)iH=img.height; with(obj.style){ W = width = iW / NX; H = height = iH / NY; L = left = x * W; T = top = y * H; } with(img.style){ width = W; height = H; } for(var i in object) object[i].DOOT(); } } } onload = function() { IMGSRC = document.getElementById("imgsrc").getElementsByTagName("img"); TXTSRC = document.getElementById("txtsrc").getElementsByTagName("div"); IMGBOX = document.getElementById("imgbox"); TXTBOX = document.getElementById("txtbox"); CENTER = document.getElementById("center"); iH = document.body.offsetHeight; iW = document.body.offsetWidth/2; nI = IMGSRC.length; var k = 0; for(var i=0;i<NY;i++){ for(var j=0;j<NX;j++){ object[k] = new CObj(k,i,j); object[k++].DOOT(); } } IMGBOX.style.width = iW; IMGBOX.style.height = iH; TXTBOX.style.width = iW; TXTBOX.style.height = iH; TXTBOX.style.left = iW; TXTBOX.style.visibility="visible"; CENTER.style.left = -iW; CENTER.style.top = -iH/2; } //--> </script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body> <div style="position:absolute;left:50%;top:50%;"><div id="center" style="position:absolute;"> <div id="imgbox" style="position:absolute;left:0;top:0;overflow:hidden;"></div> <div id="txtbox" style="position:absolute;visibility:hidden;overflow:hidden;background:#333;color:#FFF;font-family:verdana;font-size:0.8em;"> <div style="margin:2%"> <h2>IMGBOX</h2>Click the thumbnails on the left for a larger image. The description connected to the clicked image is displayed here. Note: for performance reasons, images are not resized and must be all of the same size. </div> </div> </div></div> <div id="imgsrc" style="visibility:hidden"> <img src="BS9097.jpg"> <img src="BS9092.jpg"> <img src="BS9084.jpg"> <img src="BS9064.jpg"> <img src="BS9050.jpg"> <img src="BS9070.jpg"> <img src="BS9079.jpg"> <img src="BS9068.jpg"> <img src="BS9039.jpg"> </div> <div id="txtsrc" style="visibility:hidden"> <div> <h2>the river</h2>Awaken from my nap by the river </div> <div> <h2>transparency</h2>Its transparency was hypnotizing. </div> <div> <h2>cold</h2>Currents of cold water played with light. </div> <div> <h2>sank in</h2>I threw a few nuts into the river. They floated for a while, then sank in. </div> <div> <h2>masked</h2>A wide stepping stone masked the water's depth. </div> <div> <h2>a glimpse</h2>Later on, I had a glimpse of the river's bed. </div> <div> <h2>forgotten</h2>The wheelchair made a noise. Again, I had forgotten about my legs. </div> <div> <h2>floated</h2>Still, I floated in oblivion of things too real. </div> <div> <h2>for me</h2>I stared fixedly at the water's open arms. The stream was singing for me. </div> </div> <!-- crossbrowser images_loading_bar - Gerard Ferrandez - www.dhteumeuleu.com - Feb 2005 --> <span id=LB0 style="position:absolute;left:50%;top:50%;"> <span style="position:absolute;font-family:arial;font-size:10px;color:#FFFFFF;left:-50;top:-18">Loading...</span> <span style="position:absolute;left:-50;top:-5;font-size:1px;width:100;height:10px;background:#333"> <span id=LB1 style="position:absolute;left:0;top:0;font-size:1px;width:0;height:10px;background:#FFFFFF"></span> </span> </span> <script> m00=document.getElementById("imgsrc").getElementsByTagName("img"); m01=m00.length;function images_loading_bar(){m02=0; for(i=0;i<m01;i++)m02+=(m00[i].complete)?1:0; document.getElementById("LB1").style.width=Math.round(m02/m01*100); if(m02==m01)setTimeout("document.getElementById('LB0').style.display='none'",128); else setTimeout("images_loading_bar()", 64);}; images_loading_bar(); </script> <!-- end of images_loading_bar code --> </body> </html>
[Ctrl+A 全选 注:
引入外部Js需再刷新一下页面才能执行
]
您可能感兴趣的文章:
JavaScript常见事件处理程序实例总结
url传递的参数值中包含&时,url自动截断问题的解决方法
Javascript的匿名函数小结
javascript上下左右定时滚动插件
Javascript别踩白块儿(钢琴块儿)小游戏实现代码
相关文章
11-08
兼容浏览器的js事件绑定函数(详解)
11-27
Javascript实例教程(19) 使用HoTMetal(2)
11-23
Webpack中loader打包各种文件的方法实例
10-05
javascript判断图片是否加载完成的方法推荐
11-22
在javascript中执行任意html代码的方法示例解读
JQuery
VUE
AngularJS
MSSql
MySQL
MongoDB
Redis
Linux
Tomcat
Nginx
网站首页
广告投放
联系我们
版权申明
联系站长