具体效果可见:http://www.huddletogether.com/projects/lightbox2/
程序下载地址:http://www.huddletogether.com/projects/lightbox2/lightbox2.02.zip
现将具体步骤说明如下:
首先下载Lightbox 2.02
解压缩后得到css、images、js三个目录以及index.htm文件,其中index.htm是演示和说明文档。
1. 在Z-Blog目录下的IMAGE里新建一个lightbox目录,将images内除了image-1.jpg和thumb-1.jpg以外的文件都上传进去。
2. 用文本编辑器打开js目录下的lightbox.js文件,修改如下:
查找替换字符串 images/ ,修改为http://URL/IMAGE/lightbox/ 记住一定要加上 /。
3. 用文本编辑器打开css目录下的lightbox.css文件,查找替换 ../images/ 为http://URL/IMAGE/lightbox/ 同样记住一定要加上 / 。
4. 将lightbox.css上传到Z-Blog目录的CSS目录下。
5. 将js目录下所有文件上传到Z-Blog目录的SCRIPT目录下。
6. 修改Z-Blog目录/FUNCTION/c_function.asp文件,在728行处开始。
原代码:
objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
objRegExp.Pattern="(\[IMG=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
objRegExp.Pattern="(\[IMG=)([0-9]*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img src=""$4"" alt="""" title="""" width=""$2""/>")
objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" src=""$2"" alt="""" title=""""/>")
objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*)(\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<img class=""float-left"" style=""float:left"" src=""$4"" alt="""" title="""" width=""$2""/>")
objRegExp.Pattern="(\[IMG_LEFT\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-left"" style=""float:left"" src=""$2"" alt="""" title=""""/>")
objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/>")
objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/>")
objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*)(\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<img class=""float-right"" style=""float:right"" src=""$4"" alt="""" title="""" width=""$2""/>")
objRegExp.Pattern="(\[IMG_RIGHT\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-right"" style=""float:right"" src=""$2"" alt="""" title=""""/>")
objRegExp.Pattern="(\[IMG=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<a href=""$6"" rel=""lightbox"" title=""$4""><img src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/></a>")
objRegExp.Pattern="(\[IMG=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<a href=""$5"" rel=""lightbox"" title=""$3""><img src=""$5"" alt=""$3"" title=""$3"" width=""$2""/></a>")
objRegExp.Pattern="(\[IMG=)([0-9]*)(\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<a href=""$4"" rel=""lightbox"" title=""""><img src=""$4"" alt="""" title="""" width=""$2""/></a>")
objRegExp.Pattern="(\[IMG\])(.+?)(\[\/IMG\])"
strContent= objRegExp.Replace(strContent,"<a href=""$2"" rel=""lightbox"" title=""""><img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" src=""$2"" alt="""" title=""""/></a>")
objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$6"" rel=""lightbox"" title=""$4""><img class=""float-left"" style=""float:left"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/></a>")
objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*),([^\n\[]*)(\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$5"" rel=""lightbox"" title=""$3""><img class=""float-left"" style=""float:left"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/></a>")
objRegExp.Pattern="(\[IMG_LEFT=)([0-9]*)(\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$4"" rel=""lightbox"" title=""""><img class=""float-left"" style=""float:left"" src=""$4"" alt="""" title="""" width=""$2""/></a>")
objRegExp.Pattern="(\[IMG_LEFT\])(.+?)(\[\/IMG_LEFT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$2"" rel=""lightbox"" title=""""><img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-left"" style=""float:left"" src=""$2"" alt="""" title=""""/></a>")
objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$6"" rel=""lightbox"" title=""$4""><img class=""float-right"" style=""float:right"" src=""$6"" alt=""$4"" title=""$4"" width=""$2"" height=""$3""/></a>")
objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*),(.*)(\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$5"" rel=""lightbox"" title=""$3""><img class=""float-right"" style=""float:right"" src=""$5"" alt=""$3"" title=""$3"" width=""$2""/></a>")
objRegExp.Pattern="(\[IMG_RIGHT=)([0-9]*)(\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$4"" rel=""lightbox"" title=""""><img class=""float-right"" style=""float:right"" src=""$4"" alt="""" title="""" width=""$2""/></a>")
objRegExp.Pattern="(\[IMG_RIGHT\])(.+?)(\[\/IMG_RIGHT\])"
strContent= objRegExp.Replace(strContent,"<a href=""$2"" rel=""lightbox"" title=""""><img onload=""ResizeImage(this,"&ZC_IMAGE_WIDTH&")"" class=""float-right"" style=""float:right"" src=""$2"" alt="""" title=""""/></a>")
7. 打开Z-Blog目录/TEMPLATE/single.html文件,在和之间加上如下代码:
<script type="text/javascript" src="http://freeskyblog.com/SCRIPT/prototype.js"></script>
<script type="text/javascript" src="http://freeskyblog.com/SCRIPT/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="http://freeskyblog.com/SCRIPT/lightbox.js"></script>
<link rel="stylesheet" href="http://freeskyblog.com/CSS/lightbox.css" type="text/css" media="screen" />
8. 同样地修改search.html catalog.html 三个文件,保存。
9. 修改Z-Blog目录/SCRIPT/common.js文件,删除末尾的:
objImage.attachEvent('onclick', function(){try{showModelessDialog(objImage.src);}catch(e){window.open(objImage.src);}});
<body onload="initLightbox()">
* 温情提示:选择内容即可分享到您的腾讯微博