Web site Generation Static page introduction--the way to generate static pages
Source: Internet
Author: User
Introduction | static | Page Generation HTML method There are only two main steps:
First, get the contents of the HTML file to be generated
Save the contents of the obtained HTML file as an HTML file
My main point here is just the first step: How to get the contents of the HTML file to be generated:
There are several ways to get the content of an HTML file at the moment:
1, this method and is written in the script to generate the HTML content, not easy to preview the content of the generated page, can not visualize the layout page, change the HTML template will be more complex. There are a lot of people in this way, but I feel that this method is the most inconvenient.
Str= "str=str& "2, the production of a separate HTML template page, dynamic content with a specific character as a mark (such as: Someone with $title$ marked as a page title), Load the contents of its templates with ADODB.stream or scripting.filesystemobject, and replace them with dynamic content (such as: replace (loaded template contents, "$title $", RS (" Title ")).
3, use XMLHTTP or ServerXMLHTTP to obtain the HTML content that the dynamic page displays:
I used to generate an instance of an HTML file:
'-----------------Shangai (Xiao-qi)
' Weburl is the dynamic page address to get
' Gethttppage (weburl) is a function to get the contents of a dynamic page
Weburl= "http://" &request.servervariables ("SERVER_NAME") & "/contact.asp?id=" &rs ("id") & "" ' Specify dynamic page address
Body=gethttppage (Weburl) ' The contents of a dynamic page address with a function
'-----------------Shangai (Xiao-qi)
The biggest advantage of this method is not to use the effort to write static template page, only the original dynamic page into the HTML static page, but the production speed is not too fast.
My common method of generating HTML is the 3rd: use XMLHTTP to get the HTML content generated by the dynamic page, and then save it as an HTML file with ADODB.stream or Scripting.FileSystemObject.
The second step is the method of generating the file:
Common useful adodb.stream generated files and Scripting.FileSystemObject generated files in ASP two kinds:
1, Scripting.FileSystemObject Generation file method:
'-----------------Shangai (Xiao-qi)
Set fso = CreateObject ("Scripting.FileSystemObject")
File=server.mappath ("To generate file path and filename. htm")
Set Txt=fso. OpenTextFile (File,8,true)
data1= File Contents using WriteLine method to generate files
Txt. WriteLine data1
data2= "File contents" to generate files using the Write method
Txt. Write data2
Txt. Close
Txt.fso
'-----------------Shangai (Xiao-qi)
2, ADODB. Stream generate File Method:
'-----------------Shangai (Xiao-qi)
Dim Objadostream
Set objadostream = Server.CreateObject ("ADODB. Stream ")
Objadostream.type = 1
Objadostream.open ()
Objadostream.write ("File content")
Objadostream.savetofile to generate file paths and file names. htm,2
Objadostream.close ()
'-----------------Shangai (Xiao-qi)
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.