我复制了一个剥离html的函数,并在代码中添加了一些额外的替换,但是当我在任何地方调用这个函数时,我得到了这段代码的错误
stripHTML(objRS("Name"))
输入是字符串,如何切换或删除类型?
Microsoft VBScript运行时错误'800a000d'类型不匹配:'stripHTML'
- function.asp
function stripHTML(strHTML)
Dim objRegExp, strOutput, tempStr
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<(.|n)+?>"
'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")
'Replace all < and > with < and >
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
strOutput = Lcase(replace(replace(trim(strOutput),"/","-")," ","-"))
strOutput = replace(replace(replace(strOutput,".","-"),"&","-"),",","")
strOutput = replace(replace(strOutput,"--","-"),"---","-")
stripHTML = strOutput 'Return the value of strOutput
Set objRegExp = Nothing
end Function
更新
我调用此函数的地方是另一个文件,其中此页面包含在顶部
有时这个函数会被另一个文件调用(例如:页脚模板)
如何使此功能在全球范围内可访问?
答案 0 :(得分:1)
正如已经指出的那样,你仍然需要处理NULL(s),否则尝试:
stripHTML(CStr(objRS("Name")))