Advanced ASP programming (14): browser & linkin

Source: Internet
Author: User
Tags file url

Author: cnbruce resending from: 5D multimedia

I. browser capabilities Components

The main function of this component is to extract and identify the version information of the client browser.

The principle is as follows: when the client browser sends a page request to the server, a User Agent HTTP title is automatically sent, which is an ASCII string that declares the browser and its version. The browser capabilities component maps the user agent to the browser specified in the browscap. ini file, and identifies the client browser through the browsertype object attributes.

If the item matching the title cannot be found in the browscap. ini file, the default browser attribute is used. If no match is found for this object and the default browser settings are not specified in the browscap. ini file, it sets each attribute to the string "unknown ".

By default, browscap. the INI file is stored in the Windows/system/inersrv (for example, 95/98 + pws4) or NT/system32/inersrv (for example, NT) directory. You can edit the text file by yourself, to add your own properties or modify the file based on the latest browser version Update file.

It can be concluded that the browser capabilities component extracts the content of a file and then compares the content to display it. How should I apply it?

1, btinfo. asp

<% Set BC = server. Createobject ("mswc. browsertype") %>
The browser name is Browser: <% = BC. browser %> <br>
The browser version is version: <% = BC. Version %> <br>
The main version of the browser is majorver: <% = BC. majorver %> <br>
The auxiliary browser version is minorver: <% = BC. minorver %> <br>
The operating platform of the browser is platform: <% = BC. Platform %> <br>

Obviously, "<% set BC = server. Createobject (" mswc. browsertype ") %>" is the creation of browser components.
The following example shows a specific feature of the browser, such as "BC. Browser.

2, btif. asp

<% Set BC = server. Createobject ("mswc. browsertype") %>
<% If BC. Frames = true then %>
The browser supports multi-window (frames) display.
<% Else %>
The browser does not support multi-window (frames) display.
<% End if %>
<Br>
<% If BC. backgroundsounds = true then %>
The browser can play background music (backgroundsounds)
<% Else %>
The browser cannot play background music (backgroundsounds)
<% End if %>
<Br>
<% If BC. Tables = true then %>
The browser supports table display.
<% Else %>
The browser does not support table display.
<% End if %>
<Br>
<% If BC. Beta = true then %>
Your browser is a beta version)
<% Else %>
Your browser is in the official version.
<% End if %>
<Br>
<% If BC. activexcotrols = true then %>
Browser supports active control
<% Else %>
The browser does not support active control.
<% End if %>
<Br>
<% If BC. Cookies = true then %>
The browser supports the cookie function.
<% Else %>
The browser does not support the cookie function.
<% End if %>
<Br>
<% If BC. VBScript = true then %>
The browser supports VBScript
<% Else %>
The browser does not support VBScript.
<% End if %>
<Br>
<% If BC. JScript = true then %>
Browser support for JScript
<% Else %>
The browser does not support JScript.
<% End if %>

This code is used to check the current browser's support for various types of web technologies, then the following can be changed according to a specific situation

3. FRAM. asp

<% Set BC = server. Createobject ("mswc. browsertype ")
If BC. Frames then
%>
<Frameset rows = "*, *">
<Frame src = "http://www.google.com">
<Frame src = "http://www.baidu.com">
</Framest>
<% Else %>
Your browser does not support the framework.
<% End if %>

Very simple: if the current browser supports the framework, the frameset is displayed; otherwise, the prompt "your browser does not support the framework" is displayed"

Of course, you should be reminded not to rely too much on this component, because it only extracts browscap. INI, and the value can be modified by the customer at any time, or the record is outdated, and cannot actually reflect the situation in the browser. Use it with caution.

Ii. Content linking component

Once we used DW for Web pages, we had the trouble: when we made a new page, we had to re-create a hyperlink for all other related pages. Once, I felt that I had done a lot of useless work. Imagine how nice it would be to have a special file responsible for page connection.

The content linking component came into being. It not only allows you to create a directory table on these pages, but also allows you to establish a dynamic connection between them, and automatically generate and update the directory table and the navigation links of the previous and subsequent web pages.

To use this component, you must first compile a directory file, that is, the sequential list file of the Web site URL. It is a text file and can be freely named. Next, compile an ASP file and automatically generate a directory page with a hyperlink based on the information provided by the directory file. If you want to create a hyperlink for each page, you can write a file that can automatically generate a hyperlink. For example, "nlink. INC ". Later, it will be included in each page of the group.

1. link.txt

redirect.asp?url=http://www.cnbruce.com/    cnbruce.com
redirect.asp?url=http://www.blueidea.com/    blueidea.com
redirect.asp?url=http://www.it365cn.com/    it365cn.com

The URL of the directory file is the link URL, and the text is the link text. Note thatTab key.

2, Link. asp

<%Set objNextLink = Server.CreateObject("MSWC.Nextlink")%>
<%
intCount = objNextLink.GetListCount("link.txt")
For i = 1 To intCount
%>
<a href="<%=objNextLink.GetNthURL("link.txt", i) %>">
<%=objNextLink.GetNthDescription("link.txt", i) %>
</a>
<br>
<%Next%>

"Set objnextlink = server. Createobject ("mswc. nextlink ")Create a connection to the nextlink component
"Objnextlink. getlistcount ("link.txt ")Number of lists extracted from the link.txt file by DIG
"Objnextlink. getnthurl ("link.txt", I)Extract the URL of line I text in the link.txt File
"Objnextlink. getnthdescription ("link.txt", I)Extract the connection text of line I in the link.txt File

3. Redirect. asp
That is, to switch to the file.

<%
Response.Clear
Response.Redirect Request.QueryString("url")
%>

Haha, do you think the "Previous Page" and "next page" functions are useless. Come back ~!

4,link1.txt

1. advanced ASP programming (1)
2. advanced ASP programming (2)
3. advanced ASP programming (3)
4. advanced ASP programming (4)

The main function is to set text and Connection

5, link1.inc

<% Set nextlink = server. Createobject ("mswc. nextlink ")
Response. write "the index number of the current article is" & nextlink. getlistindex ("link1.txt") & "<br>"
Response. write "the title of the previous chapter:" & nextlink. getpreviusdescription ("link1.txt") & "<br>"
Response. write "the title of the next chapter:" & nextlink. getnextdescription ("link1.txt") & "<br>"
Count = nextlink. getlistcount ("link1.txt ")
Response. write "<a href =" "& nextlink. getnthurl ("link1.txt", 1) & "" &> "&" Chapter 1 "&" </a>"
Response. Write "<a href =" "& nextlink. getpreviusurl (" link1.txt ") &" "&>" & "previous chapter" & "</a>"
Response. Write "<a href =" "& nextlink. getnexturl (" link1.txt ") &" "&>" & "Next Chapter" & "</a>"
Response. write "<a href =" "& nextlink. getnthurl ("link1.txt", count) & "" &> "&" last chapter "&" </a> <br>"
%>


Getlistcount (target file name) displays the number of connected files in the component.
Getlistindex (target file name) displays the index values of the current page before and after these connection files.
Getnextdescription (target file name) displays the next description in the connection file.
Getnexturl (target file name) displays the URL of the next file in the connection file.
Getnthdescription (target file name, n) displays the description of the N web pages in the connection file.
Getnthurl (target file name, n) displays the File URL address of the nth web page in the connection file.
Getpreviusdescription (target file name) displays the description of the previous file in the connection file.
Getpreviusurl (target file name) displays the URL of the previous file in the connection file.

6, 1.asp, 2.asp, 3.asp, 4.asp

<! -- # Include file = "link1.inc" --> <br>
The following content

This is a simple paging program. Of course there will be more detailed and complex pages later. Come on, huh, huh.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.