我用asp生成html文件,想在刷新html文件时某个图片按照0-9的随机数显示,我做不了,望高人指点! 100

我用asp生成html文件,想在刷新html文件时某个图片按照0-9的随机数显示,我做不了,望高人指点!web_string=web_string+"<tdwidth="... 我用asp生成html文件,想在刷新html文件时某个图片按照0-9的随机数显示,我做不了,望高人指点!
web_string=web_string+" <td width=""614"" height=""246"" align=""right"" valign=""bottom"" background=""../image/
web_string=web_string+"<script language=""JavaScript"">"&vbcrlf
web_string=web_string+"rnd.today=new Date(); "&vbcrlf
web_string=web_string+"rnd.seed=rnd.today.getTime(); "&vbcrlf
web_string=web_string+"function rnd() { "&vbcrlf
web_string=web_string+"rnd.seed = (rnd.seed*9301+49297) % 233280; "&vbcrlf
web_string=web_string+"return rnd.seed/(233280.0); "&vbcrlf
web_string=web_string+"}; "&vbcrlf
web_string=web_string+"function rand(number) { "&vbcrlf
web_string=web_string+"return Math.ceil(rnd()*number); "&vbcrlf
web_string=web_string+"}; "&vbcrlf
web_string=web_string+"document.write(rand(9));"&vbcrlf
web_string=web_string+"</script>"&vbcrlf
web_string=web_string+".gif"

将上面的web_string内容生成html,<script></script>之间的代码不能执行,显示在叶面中。
展开
 我来答
wxl578016349
2008-05-07 · TA获得超过371个赞
知道小有建树答主
回答量:357
采纳率:0%
帮助的人:0
展开全部
ASP生成HTM静态页的思想:代码算是最简单的,直接保存成一个asp文件即可,只要把URL(要转化的asp地址)和dizhi(要保存的html地址)设置好就可以了,一般这两个文件在同一个目录,才能保证图片或者css、js起作用。ASP生成静态Html的几种方法:http://www.foreweb.com/Article/200610/135.html
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
妈妈说名字太长不记得
2008-05-08 · 知道合伙人互联网行家
妈妈说名字太长不记得
知道合伙人互联网行家
采纳数:3729 获赞数:5729
计算机网络三级证书 从事网站开发10年经验

向TA提问 私信TA
展开全部
用JS的random()

<script LANGUAGE="JavaScript">
var index = Math.floor(Math.random() * 11);
document.write("<BODY BACKGROUND=D:\"+ index +".jpg>");
</script>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友386cf9699
2008-05-07 · TA获得超过3997个赞
知道大有可为答主
回答量:2831
采纳率:50%
帮助的人:2834万
展开全部
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnStr
Template = LoadFile("demo.html")
Template = Replace_DB_HTML_Labels(Template)
Template = Replace_DB_ASP_Labels(Template)
Template = Replace_Page_ASP_Labels(Template)
Response.write Template
conn.close
Set conn = nothing
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function Get_Labels_Content(lable_code)
Dim TempStr
Set rs = Server.CreateObject("ADODB.RecordSet")
sql = "SELECT top 1 [Content] FROM [Tags] WHERE [alies]='" & lable_code & "'"
rs.Open sql,conn, 1,1
If Not rs.EOF Then
TempStr = rs("Content")
End If
rs.Close
Set rs = Nothing
Get_Labels_Content = TempStr
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = False
regEx.Global = True
Set Matches = regEx.Execute(strng)
For Each Match in Matches
RetStr = RetStr & Match&"###"
Next
RegExpTest = RetStr
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function StaticTitle(str)
no=len(str)-2
StaticTitle=mid(str,2,no)
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function tempTitle(str)
no1=instr(str,"(")
tempTitle=mid(str,3,no1-3)
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function TempInfo(str)
n1=instr(str,"(")
n2=instr(str,")")
TempInfo=Mid(str,n1+1,n2-n1-1)
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function Replace_Page_ASP_Labels(str_P)
strinfo1 = RegExpTest("{![^<>]+?!}", str_P)
If strinfo1<>"" Then
arrinfo = Split(strinfo1,"###")
For i = 0 To Ubound(arrinfo)-1
If instr(arrinfo(i),"(")>0 Then
FunTitle=tempTitle(arrinfo(i))
arry=TempInfo(arrinfo(i))
'On Error Resume Next
str_P=Replace(str_P,arrinfo(i),Eval(FunTitle&"("&arry&")"))
Else
statitle=statictitle(arrinfo(i))
'On Error Resume Next
str_P=Replace(str_P,arrinfo(i),Eval(statitle))
End If
Next
End If
Replace_Page_ASP_Labels=str_P
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function Replace_DB_HTML_Labels(str_H)
' On Error Resume Next
Dim objRegEx, MyLables, MyLable, o_MyLable, o_MyCode
Set objRegEx = New RegExp
objRegEx.IgnoreCase = true
objRegEx.Global = True
objRegEx.Pattern = "{\$[^<>]+?\$}"
Set MyLables = objRegEx.Execute(str_H)
For Each MyLable in MyLables
o_MyLable = MyLable.Value
o_MyCode = Split(MyLable.Value, "$")(1)
str_H = Replace(str_H, MyLable.Value, Get_Labels_Content(o_MyCode))
Next
Set MyLables = Nothing
Set objRegEx = Nothing
Replace_DB_HTML_Labels = str_H
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function Replace_DB_ASP_Labels(str_D)
Dim objRegEx, MyLables, MyLable, o_MyLable, o_MyCode
Set objRegEx = New RegExp
objRegEx.IgnoreCase = true
objRegEx.Global = True
objRegEx.Pattern = "{#\w+(\((\b[,0-9]+\b)?\))?#}"
Set MyLables = objRegEx.Execute(str_D)
For Each MyLable in MyLables
o_MyLable = MyLable.Value
o_MyCode = Split(MyLable.Value, "#")(1)
s_MyCode = Get_Labels_Content(o_MyCode)
str_D = Replace(str_D, MyLable.Value, Eval(s_MyCode))
Next
Set MyLables = Nothing
Set objRegEx = Nothing
Replace_DB_ASP_Labels = str_D
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式