输入内容:cnbruce love cnrose
输入查询内容: cn
你会发现结果的。
[code]
<script language=javascript> strText=window.prompt("请输入内容:"); strFind=window.prompt("请输入查询内容:"); </script>
<script language=vbs> Function Highlight(strText, strFind, strBefore, strAfter) Dim nPos Dim nLen Dim nLenAll nLen = Len(strFind) nLenAll = nLen + Len(strBefore) + Len(strAfter)
Highlight = strText
If nLen > 0 And Len(Highlight) > 0 Then nPos = InStr(1, Highlight, strFind, 1) Do While nPos > 0 Highlight = Left(Highlight, nPos - 1) & _ strBefore & Mid(Highlight, nPos, nLen) & strAfter & _ Mid(Highlight, nPos + nLen)
nPos = InStr(nPos + nLenAll, Highlight, strFind, 1) Loop End If End Function
document.write(Highlight(strText, strFind, "<font color=red>", "</font>")) </script> [/code] 
|