原文出处:http:///faq/faq_notes/closures.html(Dnew.CN注)
Aglobalvariable-getImgInPositionedDivHtml-isdeclaredand
assignedthevalueofaninnerfunctionexpressionreturnedfrom
aone-timecalltoanouterfunctionexpression.
ThatinnerfunctionreturnsastringofHTMLthatrepresentsan
absolutelypositionedDIVwrappedroundanIMGelement,suchthat
allofthevariableattributevaluesareprovidedasparameters
tothefunctioncall:-
*/
vargetImgInPositionedDivHtml=(function(){
varbuffAr=[
'<divid="',
'',//index1,DIVIDattribute
'"style="position:absolute;top:',
'',//index3,DIVtopposition
'px;left:',
'',//index5,DIVleftposition
'px;width:',
'',//index7,DIVwidth
'px;height:',
'',//index9,DIVheight
'px;overflow:hidden;\"><imgsrc=\"',
'',//index11,IMGURL
'\"width=\"',
'',//index13,IMGwidth
'\"height=\"',
'',//index15,IMGheight
'\"alt=\"',
'',//index17,IMGalttext
'\"><\/div>'
];
return(function(url,id,width,height,top,left,altText){
buffAr[1]=id;
buffAr[3]=top;
buffAr[5]=left;
buffAr[13]=(buffAr[7]=width);
buffAr[15]=(buffAr[9]=height);
buffAr[11]=url;
buffAr[17]=altText;
returnbuffAr.join('');
});//:Endofinnerfunctionexpression.
})();
