永发信息网

ASP 提取图片的问题 高手请进!

答案:1  悬赏:0  手机版
解决时间 2021-07-19 03:21
  • 提问者网友:半生酒醒
  • 2021-07-18 05:10

Function ImgOutReplace(ImgStr,ImgW,ImgH)
Dim Imgi,Imgj,Imgk,Imgm,Imgn,ImgReStr,Imgtext,ImgNum
If IsNull(ImgStr) Or ImgStr="" Then
Exit Function
Else
ImgReStr = ""
ImgStr = Replace(ImgStr,vbCrLf,"")
Imgtext = ImgStr
Imgk = Len(ImgStr)
For Imgi = 0 To Imgk
If Instr(ImgStr,"<") > 0 Then
Imgn = ""
Imgm = ""
Imgj = ""
Imgn = Instr(ImgStr,"<")
Imgm = Instr(ImgStr,">")
ImgNum = Imgm-Imgn+1
Imgj = Imgn+1
If Lcase(Mid(ImgStr,Imgj,3)) = "img" Then
On Error Resume Next
ImgReStr = Mid(ImgStr,Imgn,ImgNum)
Exit For
ElseIf Mid(ImgStr,Imgj,1) <> " " Then
On Error Resume Next
ImgReStr = Mid(ImgStr,Imgn,ImgNum)
ImgStr = Replace(ImgStr,ImgReStr,"")
ImgReStr = ""
End If
ElseIf Instr(Lcase(ImgStr),"&lt;") > 0 Then
Imgn = ""
Imgm = ""
Imgj = ""
Imgn = Instr(Lcase(ImgStr),"&lt;")
Imgm = Instr(Lcase(ImgStr),"&gt;")
ImgNum = Imgm-Imgn+4
Imgj = Imgn+4
If Lcase(Mid(ImgStr,Imgj,3)) = "img" Then
On Error Resume Next
ImgReStr = Mid(ImgStr,Imgn,ImgNum)
Exit For
ElseIf Mid(ImgStr,Imgj,1) <> " " Then
On Error Resume Next
ImgReStr = Mid(ImgStr,Imgn,ImgNum)
ImgStr = Replace(ImgStr,ImgReStr,"")
ImgReStr = ""
End If
End If
Next
If IsNull(ImgReStr) Or ImgReStr="" Then
ImgStr = ""
Else
ImgStr = ImgReStr
End If
End If
ImgStr = Replace(Lcase(ImgStr),"src"," onload='javascript:DrawImage(this,"&ImgW&","&ImgH&");' onmouseover='javascript:DrawImage(this,"&ImgW&","&ImgH&");' src")
ImgOutReplace = CheckStr(ImgStr,3)
ImgStr = ""
End Function%>
<%call ImgOutReplace(titdle,100,100)%>'子函数说明:内容,图片宽,图片高

这段代码有错吗?

为什么显示不出来图片

最佳答案
  • 五星知识达人网友:山河有幸埋战骨
  • 2021-07-18 05:25

呃·我来回答下·别忘给分··


看了下函数·呃·有点眼花··用正则 会更简单些··



ImgOutReplace = CheckStr(ImgStr,3) CheckStr 这个函数不知道是干什么的·你没给·截取文件类型??所以我把它删了··


ImgOutReplace = ImgStr



下面你出错的地方在这里了·


<%call ImgOutReplace(titdle,100,100)%>


呵呵··你这是 function 啊··


response.write ImgOutReplace ("<img src=ttt.jpg>",100,100)


呃··不知道你的 titdle 是什么·我用一个调用替换了·下·结果是可以提取到 ttt.jpg 的··


<img onload='javascript:DrawImage(this,100,100);' onmouseover='javascript:DrawImage(this,100,100);' src=ttt.jpg>



给分吧 :)

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯