以下这个更好
Java代码
$.showad=function(src,width,height,num,top,distance){
var i,m,l,t;
var dw=width/num;
height=height/2;
distance=distance/2;
var left=($(document).width()-width)/(num+1);
var leftl=left*(num+1)/2;
var $l=new Array();
var $t=new Array();
$('html,body').animate({scrollTop: 0});
$('<div></div>',{
id:'hBg',
css:{
width:'100%',
height(document).height(),
background:'#000',
display:'none',
position:'absolute',
left:0,
top:0,
zIndex:998
}
}).appendTo('body').fadeTo("slow", 0.8,function(){
for(i=0;i<2;i++){
for(m=0;m<num;m++){
l=left*(m+1)+dw*m;
t=top-distance+i*(height+2*distance);
$('<div></div>',{
id:'adb'+(m+i*num),
width:dw,
height:height,
css:{
position:'absolute',
background:'#000 url(\''+src+'\') no-repeat '+m*(-dw)+'px '+(-i*height)+'px',
display:'none',
zIndex:'999',
left:l,
top:t
}
}).appendTo('body').animate({left:leftl+dw*m,top:top+height*i,opacity:'show'},'slow');
$l.push(l);
$t.push(t);
}
}
}).click(function(){
num=num*2;
for(i=0;i<num;i++){
$('#adb'+i).stop().animate({leftl[i],topt[i],opacity:'hide'},'1000',function(){
$(this).remove();
});
}
$(this).remove();
})
}
$.showad=function(src,width,height,num,top,distance){
var i,m,l,t;
var dw=width/num;
height=height/2;
distance=distance/2;
var left=($(document).width()-width)/(num+1);
var leftl=left*(num+1)/2;
var $l=new Array();
var $t=new Array();
$('html,body').animate({scrollTop: 0});
$('<div></div>',{
id:'hBg',
css:{
width:'100%',
height(document).height(),
background:'#000',
display:'none',
position:'absolute',
left:0,
top:0,
zIndex:998
}
}).appendTo('body').fadeTo("slow", 0.8,function(){
for(i=0;i<2;i++){
for(m=0;m<num;m++){
l=left*(m+1)+dw*m;
t=top-distance+i*(height+2*distance);
$('<div></div>',{
id:'adb'+(m+i*num),
width:dw,
height:height,
css:{
position:'absolute',
background:'#000 url(\''+src+'\') no-repeat '+m*(-dw)+'px '+(-i*height)+'px',
display:'none',
zIndex:'999',
left:l,
top:t
}
}).appendTo('body').animate({left:leftl+dw*m,top:top+height*i,opacity:'show'},'slow');
$l.push(l);
$t.push(t);
}
}
}).click(function(){
num=num*2;
for(i=0;i<num;i++){
$('#adb'+i).stop().animate({leftl[i],topt[i],opacity:'hide'},'1000',function(){
$(this).remove();
});
}
$(this).remove();
})
}
|