Highlight keywords
JavaScript code is as follows
function HightLight (nWord) {var oRange = document.body.createTextRange (); while (oRange.findText (nWord)) {oRange.pasteHTML ( "" oRange.text " span>"); Orange.MoveStart ('Character', 1);}}
If you use it in VB, improve it.
Public Sub HightLight2 (nKey $, nDoc As MSHTML.HTMLDocument, Optional beforeTag $ = "", Optional afterTag $ = "") On Error Resume NextDim tBody As MSHTML.HTMLBodyDim oRange As MSHTML.IHTMLTxtRange
If BeforeetaG = "" the beforeetaG = "" end ifif offrtag = "" "" ends "end if
Set tBody = nDoc.bodyIf Not tBody Is Nothing Then Set oRange = tBody.createTextRange If Not oRange Is Nothing Then While oRange.FindText (nKey) Call oRange.pasteHTML (beforeTag & oRange.Text & afterTag) Call oRange.MoveStart ( "character ", 1) Wend end iFend IFEND SUB
If there are multiple frames in the page, then you need to do some work, I will not write.
LINGLL (Lingll2001@21cn.com) 2004-7-5
Supplement: Enumerates Frame You can refer to the following article http://www.mvps.org/emorcillo/vb6/inet/wbframe.shtml
.
Note: this Tip is based on the Microsoft Kb Article 196340 and Requieres the Oleelib.tlb Type Library.
Sub Enumframes (Byval WB AS Webbrowser) Dim PContainer As Oleelib.iolecontainerdim Penumerator As OleLib.ienumunknownDim Punk As OleLib.iunknownDim PBROWSER As Shdocvw.iWebBrowser2