内容链接组件
建立一个目录。
内容链接组件 2
使用内容链接组件在文本文件的页面之间导航。
ASP 内容链接组件用于创建快速且简单的导航系统!
内容链接组件返回一个 Nextlink 对象,该对象用于保存要导航的网页列表。
<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>
首先我们创建一个文本文件 - "links.txt":
asp_intro.html ASP Intro
asp_syntax.html ASP Syntax
asp_variables.html ASP Variables
asp_procedures.html ASP Procedures
上面的文本文件包含要导航的页面。页面的列出顺序必须与您希望显示的顺序相同,并且还必须包含每个文件名的说明(使用 Tab 键将文件名与说明分开)。
笔记:如果您想添加页面,或更改页面在列表中的顺序;您只需修改文本文件即可!导航会自动修正!
然后我们创建一个包含文件"nlcode.inc"。 .inc 文件创建一个 NextLink 对象以在 "links.txt" 中列出的页面之间导航。
"nlcode.inc":
<%
dim nl
Set nl=Server.CreateObject("MSWC.NextLink")
if (nl.GetListIndex("links.txt")>1) then
Response.Write("<a href='" & nl.GetPreviousURL("links.txt"))
Response.Write("'>Previous Page</a>")
end if
Response.Write("<a href='" & nl.GetNextURL("links.txt"))
Response.Write("'>Next Page</a>")
%>
在文本文件 "links.txt" 列出的每个 .html 页面中,放置一行代码:<!-- #include 文件="nlcode.inc"-->。此行将在"links.txt" 中列出的每个页面上包含"nlcode.inc" 中的代码,并且导航将正常工作。
Method | Description | Example |
---|---|---|
GetListCount | Returns the number of items listed in the Content Linking List file | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetListCount("links.txt") Response.Write("There are ") Response.Write(c) Response.Write(" items in the list") %> Output: There are 4 items in the list |
GetListIndex | Returns the index number of the current item in the Content Linking List file. The index number of the first item is 1. 0 is returned if the current page is not in the Content Linking List file | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetListIndex("links.txt") Response.Write("Item number ") Response.Write(c) %> Output: Item number 3 |
GetNextDescription | Returns the text description of the next item listed in the Content Linking List file. If the current page is not found in the list file it returns the text description of the last page on the list | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetNextDescription("links.txt") Response.Write("Next ") Response.Write("description is: ") Response.Write(c) %> Next description is: ASP Variables |
GetNextURL | Returns the URL of the next item listed in the Content Linking List file. If the current page is not found in the list file it returns the URL of the last page on the list | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetNextURL("links.txt") Response.Write("Next ") Response.Write("URL is: ") Response.Write(c) %> Next URL is: asp_variables.html |
GetNthDescription | Returns the description of the Nth page listed in the Content Linking List file | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetNthDescription("links.txt",3) Response.Write("Third ") Response.Write("description is: ") Response.Write(c) %> Third description is: ASP Variables |
GetNthURL | Returns the URL of the Nth page listed in the Content Linking List file | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetNthURL("links.txt",3) Response.Write("Third ") Response.Write("URL is: ") Response.Write(c) %> Third URL is: asp_variables.html |
GetPreviousDescription | Returns the text description of the previous item listed in the Content Linking List file. If the current page is not found in the list file it returns the text description of the first page on the list | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetPreviousDescription("links.txt") Response.Write("Previous ") Response.Write("description is: ") Response.Write(c) %> Previous description is: ASP Variables |
GetPreviousURL | Returns the URL of the previous item listed in the Content Linking List file. If the current page is not found in the list file it returns the URL of the first page on the list | <% dim nl,c Set nl=Server.CreateObject("MSWC.NextLink") c=nl.GetPreviousURL("links.txt") Response.Write("Previous ") Response.Write("URL is: ") Response.Write(c) %> Previous URL is: asp_variables.html |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!