<html>
<head>
<title>一款媲美FLASH的图片交替效果-网页特效-www.25175.com</title>
<meta name="Author" content="http://www.25175.com">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body {cursor:crosshair;margin:0; padding:0; position:absolute; overflow:hidden; background:#222; left:0;
top:0; width:100%; height:100%;zIndex:-2;}
a.c:link { color: #ffffff; text-decoration: none ; font-size:20px}
a.c:visited { color: #ffffff; text-decoration: none ; font-size:20px}
a.c:active { color: #ffffff; text-decoration: underline; font-size:20px}
a.c:hover { color: #ffffff; text-decoration: underline; font-size:20px}
</style>
<SCRIPT language=JavaScript>
<!--
// =================by www.qpsh.com
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>
</head>
<body>
<base target=_blank>
<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;; line-height:150%" >
<div style="margin:2%">
<a class=c href=http://www.25175.com><h2>[网页特效]</h2></a>网页特效是用程序代码在网页中实现特殊效果或者特殊
功能的一种技术,它为网页活跃了气氛,增加了网站的亲和力。
</div>
</div>
</div></div>
<div id="imgsrc" style="visibility:hidden">
<img src="BS9068.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><a class=c href=http://www.25175.com>[菜单特效]</a></h2><br>一般在你想添加特效的地方直接粘贴特效代码即可
,有些特殊的代码还需要在别的地方添加其他代码。在本站下载的特效代码,都有详细说明,按说明使用即可。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[窗口页面]</a></h2><br>随着网络的发展,网速和机器速度的提高,越来越
多的网站用到了丰富客户端技术。而现在Ajax则是最为流行的一种方式。javascript是一种解释型语言,所以能无法达到和
C/Java之类的水平,限制了它能在客户端所做的事情,为了能改进他的性能,我想基于我以前给JavaScript做过的很多测试来
谈谈自己的经验,希望能帮助大家改进自己的JavaScript脚本性能。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[文本操作]</a></h2><br>因为JavaScript的解释性,所以a.b.c.d.e,需要
进行至少4次查询操作,先检查a再检查a中的b,再检查b中的c,如此往下。所以如果这样的表达式重复出现,只要可能,应该
尽量少出现这样的表达式,可以利用局部变量,把它放入一个临时的地方进行查询。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[按钮链接]</a></h2><br>这一点可以和循环结合起来,因为我们常常要根据
字符串、数组的长度进行循环,而通常这个长度是不变的,比如每次查询a.length,就要额外进行一个操作,而预先把var
len=a.length,则就少了一次查询。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[图形图象]</a></h2><br>其实这个影响倒比较小,可以忽略。什么叫使用直
接量,比如,JavaScript支持使用[param,param,param,...]来直接表达一个数组,以往我们都使用new Array
(param,param,...),使用前者是引擎直接解释的,后者要调用一个Array内部构造器,所以要略微快一点点。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[按钮链接]</a></h2><br>很多人喜欢在JavaScript中使用document.write来
给页面生成内容。事实上这样的效率较低,如果需要直接插入HTML,可以找一个容器元素,比如指定一个div或者span,并设
置他们的innerHTML来将自己的HTML代码插入到页面中。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[窗口页面]</a></h2><br>所以应该是用document.createElement()方法,而
如果文档中存在现成的样板节点,应该是用cloneNode()方法,因为使用createElement()方法之后,你需要设置多次元素的属
性,使用cloneNode()则可以减少属性的设置次数——同样如果需要创建很多元素,应该先准备一个样板节点。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[时间日期]</a></h2><br>文件优化也是一个很有效的手段,删除所有的空格
和注释,把代码放入一行内,可以加快下载的速度,注意,是下载的速度而不是解析的速度,如果是本地,注释和空格并不会
影响解释和执行速度。
</div>
<div>
<h2><a class=c href=http://www.25175.com>[警告对话]</a></h2><br>同时,一些基本的算法上的优化,同样可以用在
JavaScript中,比如运算结构的调整,这里就不再赘述了。但是由于JavaScript是解释型的,一般不会在运行时对字节码进行
优化,所以这些优化仍然是很重要的。
</div>
</div>
<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>
</body>
</html>
by 25175.com