我理解你的问题是生成动态网页是吧。一般动态的HTML是通过支持CGI 即 (通用网关接口)的语言生成的。例如 PHP ASP PYTHON RUBY等。当然前段的JS 也可以通过DOM 生成动态HTML
所谓HTML实际上是一种标记语言。而后端脚本语言通常可以控制 终端设备输出显示。这样利用输出加上通用网关接口就可以实现 动态的HTML输出(在这里实际上用户浏览器就是一个终端。)
一般后台语言生成HTML都是通过模板实现 例如PYTHON
# ! / u s r / b i n / e n v p y t h o nimport cgi
reshtml = '''Content-Type: text/html\n
<HTML><HEAD><TITLE> 7 Friends CGI Demo (dynamic screen)
</TITLE></HEAD>
<BODY><H3>Friends list for: <I>%s</I></H3>
Your name is: <B>%s</B><P>
You have <B>%s</B> friends.
</BODY></HTML>'''
form = cgi.FieldStorage()
who = form['person'].value howmany = form['howmany'].value print reshtml %
(who, who, howmany)
生成首页用ajax主要是 xmlhttp与 stream 的用法
这是生成html的代码:参考一下吧;
网上也有很多 ,都是这样的
看一下这个函数: SaveFile(LocalFileName,RemoteFileUrl)
<%
set conn=server.CreateObject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)}dbq="&server.MapPath("/test1/test.mdb")
set rs=server.CreateObject("adodb.recordset")
sql="select * from test order by time desc "
rs.open sql,conn,1,1
rs.PageSize=4
if SaveFile("index.html","http://"&Request.ServerVariables("server_name")&"/test1/index.asp") then
Response.write "<div style='text-align:centerwidth:100%color:Greenmargin:20px autofont-size:16px'><br>index.html首页生成成功!<br></div>"
else
Response.write "<div style='text-align:centerwidth:80%color:Greenmargin:20px autofont-size:16px'><br>对不起!<br><br>index.html首页生成失败!<br></div>"
end if
for i=1 to rs.pagecount
if SaveFile("index_"&i&".html","http://"&Request.ServerVariables("server_name")&"/test1/index.asp?page="&i&"") then
Response.write "<div style='text-align:centerwidth:100%color:Greenmargin:20px autofont-size:16px'><br>index_"&i&".html生成成功!<br></div>" '生成列表页!
else
Response.write "<div style='text-align:centerwidth:80%color:Greenmargin:20px autofont-size:16px'><br>index_"&i&".html生成失败!<br></div>"
end if
next
function SaveFile(LocalFileName,RemoteFileUrl)
Dim Ads, Retrieval, GetRemoteData
On Error Resume Next
Set Retrieval = Server.CreateObject("Microso" &"ft.XM" &"LHTTP")
With Retrieval
.Open "Get", RemoteFileUrl, False, "", ""
.Send
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
Set Ads = Server.CreateObject("Ado" &"db.Str" &"eam")
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile Server.MapPath(LocalFileName), 2
.Cancel()
.Close()
End With
Set Ads=nothing
if err <>0 then
SaveFile = false
err.clear
else
SaveFile = true
end if
End function
%>