Introductory steps for ASP Programming (14): Browser & Linkin

Source: Internet
Author: User
Tags file url ini client
Programming one, Browser capabilities components

The main function of this component is to extract the version information that identifies the client browser.

The rationale is this: When a client browser sends a page request to the server, it automatically sends a user Agent HTTP header, which is an ASCII string that declares the browser and its version. The browser Capabilities component maps the user agent to the browser indicated in the file Browscap.ini and identifies the client browser through the BrowserType object's properties.

If the object does not find an entry in the Browscap.ini file that matches the title, the default browser properties are used. If the object does not find a match and the default browser setting is not specified in the Browscap.ini file, it sets each property to the string "UNKNOWN".

By default, browscap.ini files are stored in windows\system\inersrv (if 95/98+pws4) or nt\system32\inersrv (if NT) directories, you can edit this text file yourself, To add your own properties or modify the file according to the latest published browser version of the update file.

It can be concluded that the Browser capabilities component is to extract the contents of a file and then compare the display. How to apply it exactly?

1,btinfo.asp


<%set Bc=server. CreateObject ("Mswc.browsertype")%> browser name is browser:<%=bc.browser%><br> browser version is version:<%= Bc.version%> <br> Browser main version is majorver:<%=bc.majorver%> <br> Browser auxiliary version is minorver:<%=bc.minorver% > <br> Browser's operating platform is platform:<%=bc.platform%> <br>
Apparently "<%set Bc=server. CreateObject ("Mswc.browsertype")%> is the creation of a browser component
The following, such as "Bc.browser", is a specific feature of the display browser.

2,btif.asp


<%set Bc=server. CreateObject ("Mswc.browsertype")%> <%if bc.frames=true then%> Browser supports multiple window (frames) display <%else%> browsers do not support multiple windows ( Frames) shows <%end if%> <br> <%if bc.backgroundsounds=true then%> browsers can play background music (backgroundsounds) <% Else%> Browser cannot play background music (backgroundsounds) <%end if%> <br><%if bc.tables=true then%> Browser support table (tables) display <%else%> browsers do not support tables (tables) to display <%end if%> <br> <%if bc.beta=true then%> Your browser is a beta beta <%else %> your browser is an official version of <%end if%> <br> <%if bc.activexcotrols=true then the%> browser support active control <%else%> Browser Active control <%end if%> <br> <%if bc.cookies=true then%> browser support cookie feature <%else%> browser does not support cookies function < %end if%> <br> <%if bc.vbscript=true then%> browsers support VBScript <%else%> browsers do not support VBScript <%end If%> & lt;br> <%if bc.jscript=true then%> browsers support JScript <%else%> browsers do not support JScript <%end if%>
The code is to detect the current browser support for various types of Web page technology, then the following can be based on a specific situation to make the corresponding changes

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 frames <%end if% >
Simple meaning: If the current browser support framework for frameset display, otherwise prompts "your browser does not support the framework"

Of course, need to remind you: do not rely too much on the component, because it is only to extract the value of Browscap.ini, and this value can be modified by the customer at any time, or record outdated, can not really reflect the situation of the browser, the use of caution.

Ii. Content Linking components

Once used DW to do Web pages have such a worry: The new page, all the other related pages have to do a hyperlink again. Once also just, a lot more can not help but feel no effort to do a lot. Imagine how good it would be if you had a special file for the page connection.

Content linking component also came into being. Not only can you create a table of contents in these pages, but you can also create dynamic connections between them and automatically generate and update navigation links to the table of contents and previous and subsequent Web pages.

To use this component, you first need to write a directory file, which is the order list file of the Web site, which is a text file that can be named freely. Second, write an ASP file, based on the information provided by the directory file automatically generated with a hyperlink directory page. If you need a "forward or backward" hyperlink on every page, write a containing file that automatically generates a page-flipping hyperlink, using Inc as an extension, such as "Nlink.inc". Later, include it in each page in the group.

1,link.txt


redirect.asp?url=http://www.cnbruce.com/cnbruce.comredirect.asp?url=http://www.blueidea.com/ Blueidea.comredirect.asp?url=http://www.it365cn.com/it365cn.com
The directory file URL is connected to the Web site, text is connected to the text, you need to note that the middle tab to separate.

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 ")" to establish a connection to the Nextlink component
"Objnextlink.getlistcount (" Link.txt ")" Extracts the number of lists in the Link.txt file
"Objnextlink.getnthurl (" Link.txt ", i)" Extracts the connection URL of line I in the Link.txt file
"Objnextlink.getnthdescription (" Link.txt ", i)" Extracts the connection text in line I of the Link.txt file

3,redirect.asp
That means turning to a file.


<%response.clearresponse.redirect request.querystring ("url")%>
Oh, do not feel that the "previous page", "next page" function. Come again, ~!.

4,link1.txt


Introduction to 1.asp ASP programming (i) 2.asp ASP Programming Entry Step (ii) 3.asp ASP Programming Introductory Step (III) 4.asp ASP programming Introductory step (d)
The main function is to set up text and connections

5,link1.inc


<%set nextlink=server.createobject ("MSWC"). Nextlink ") Response.Write" Current article index number is "& Nextlink.getlistindex (" Link1.txt ") &" <br> "Response.Write" Title of the previous chapter: "& Nextlink.getpreviousdescription (" Link1.txt ") &" <br> "Response.Write" The title of the next chapter: "& Nextlink.getnextdescription (



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.