论述使用ASP读取HTML模版的方法(附代码)
发布时间:2023-07-26 14:22:09 所属栏目:Asp教程 来源:
导读:在实际工作中我们经常要使用到模版,这样不仅保证了每页的一致性,也减少了我们的工作量,本文介绍怎么使用ASP读取HTML模版的方法(附代码)
模片页面: m.htm
标题:{title}
内容:{content}
调用页面
模片页面: m.htm
标题:{title}
内容:{content}
调用页面
在实际工作中我们经常要使用到模版,这样不仅保证了每页的一致性,也减少了我们的工作量,本文介绍怎么使用ASP读取HTML模版的方法(附代码) 模片页面: m.htm 标题:{title} 内容:{content} 调用页面 xxx.ASP My_moban=LoadFile("m.htm") If My_moban <> "" then My_moban=(replace(My_moban,"{title}",错新网” My_moban=(replace(My_moban,"{content}","http://www.cuoxin.com")) Response.Write My_moban end if Function LoadFile(m_Root) Dim Filename,fso,hndFile Filename = m_Root If Right(Filename, 1)<>"/" And Right(Filename, 1)<>"/" Then Filename = Filename & "/" Filename = Server.MapPath(Filename & m_FileName) Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(Filename) Then response.write("模板文件" & m_FileName & "不存在!") :response.end set hndFile = fso.OpenTextFile(Filename) if not hndFile.atendofstream then LoadFile = hndFile.ReadAll end if Set hndFile = Nothing Set fso = Nothing If LoadFile = "" Then response.write("不能读取模板文件" & m_FileName & "或文件为空!"):response.end End Function 以上方法仅供参考,大家可以举一反三。 (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐