刚从PJBLOG转到Z-BLOG,还不是很习惯,Z-BLOG内置的首页调用不错,但是不太适合我的需要,为此,特改造一个自定义的最新日志调用。只显示日志标题,并自动用CSS截取多余的字符长度,超链接在新窗口打开。用法很简单,把以下代码保存为一个新文件,然后上传到z-blog根目录,并在外部调用之,调用条数可以在z-blog后台修改,调用代码如下: <script type="text/javascript" charset="utf-8" src="http://1982y.net.cn/topblog.asp"></script>,可根据需要改成自己的z-blog地址。
预览:http://www.wind88.net

源代码如下:
ASP/Visual Basic代码
- <%@ CODEPAGE=65001 %>
- <%
- '==================================
- '首页调用文件 topBlog.asp
- '风易博客 http://1982Y.Net.Cn
- %>
- <% Option Explicit %>
- <% On Error Resume Next %>
- <% Response.Charset="UTF-8" %>
- <% Response.Buffer=True %>
- <% Response.ContentType="application/x-javascript" %>
- <!-- #include file="c_option.asp" -->
- <!-- #include file="function/c_function.asp" -->
- <!-- #include file="function/c_system_base.asp" -->
- <%
- Response.Clear
- Response.Write "document.write(""" & LoadFileInfo("previous") & """)"
- Response.End
- Function LoadFileInfo(name)
- Dim strContent,str
- Dim objStream
- Dim i,j
- Dim aryTemplateTagsName
- Dim aryTemplateTagsValue
- Application.Lock
- aryTemplateTagsName=Application(ZC_BLOG_CLSID & "TemplateTagsName")
- aryTemplateTagsValue=Application(ZC_BLOG_CLSID & "TemplateTagsValue")
- Application.UnLock
- j=UBound(aryTemplateTagsName)
- For i=1 to j
- If aryTemplateTagsName(i)="TEMPLATE_INCLUDE_" & UCase(name) Then
- strContent=aryTemplateTagsValue(i)
- Exit For
- ElseIf aryTemplateTagsName(i)="CACHE_INCLUDE_" & UCase(name) Then
- strContent=aryTemplateTagsValue(i)
- End If
- Next
- Dim reg, objMatches
- Set reg = new RegExp
- reg.IgnoreCase = True
- reg.Global = True
- '一日期,二日期,三标题
- reg.Pattern = "(http://[^\s]+)"".+?span.+?\[(.+?)\].+?>(.+?)<"
- Set objMatches = reg.Execute(strContent)
- If objMatches.Count > 0 Then
- For i = 0 To objMatches.Count - 1
- str = str & "<div style='width:145px;overflow:hidden;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;'><a href="""&objMatches(i).SubMatches(0)""" target=""_blank"" title="""&toUnicode(objMatches(i).SubMatches(2))""" style=""color:#0469C4;TEXT-DECORATION: none"">"&toUnicode(objMatches(i).SubMatches(2))"</a></div>"
- Next
- End If
- str= Replace(str,"\","\\")
- str= Replace(str,"/","\/")
- str= Replace(str,"""","'")
- str= Replace(str,vbCrLf,"")
- str= Replace(str,vbLf,"")
- LoadFileInfo=str
- End Function
- function toUnicode(str) 'To Unicode
- dim i, unicodeF, getUnicode
- for i=1 to len(str)
- unicodeF=Mid(str,i,1)
- getUnicode=getUnicode & chr(38) & chr(35) & chr(120) & Hex(ascw(unicodeF)) & chr(59)
- next
- toUnicode=getUnicode
- end function
- %>

订阅我的BLOG(RSS)