asp截取字符串问题
<%
str1= ".....// <img height= " "0 " " width= " "0 " " alt= " " " " src= " "/science/upload_editpic/Image/events_p06.gif " " /> .... "
sub getPath(str1)
Dim imagestart, imageend
Dim str3, str2, str4, str5
imagestart=InStr(1,str1, " <img ",1)
str2=Mid(str1,imagestart)
imageend=InStr(1,str2, "> ",1)
str1=Mid(str2,1,12)
end sub
%>
<td> ssssssssss </td>
<a onclick= " <%call getPath(str1)%> "> dddd <%=str1%> </a>
str1为一段不定长字符串,写一个方法取得第一个 <img /> 中的 src 的内容,即取出第一个image的路径。。。
------解决方案--------------------这种情况可以考虑放到客户端DOM中进行取值!比较方便!
------解决方案--------------------用split吧
------解决方案-------------------- <%
str1= ".....// <img height= " "0 " " width= " "0 " " alt= " " " " src= " "/science/upload_editpic/Image/events_p06.gif " " /> .... "
sub getPath(str1)
Dim imagestart, imageend
Dim str3, str2, str4, str5
imagestart=InStr(1,str1, " <img ",1)
srcstart=instr(imagestart,str1, "src ")
srcend=instr(srcstart+6,str1, " " " ")
response.write mid(str1,srcstart+5,srcend-srcstart-5)
'str2=Mid(str1,imagestart)
'imageend=InStr(1,str2, "> ",1)
'str1=Mid(str2,1,12)
end sub
%>
<%call getPath(str1)%>
上面的代码是有问题的
要在客户端用onclick,那就应该写客户端脚本,而不是asp,asp是服务器端脚本