开发者

How to insert Html anchor Tag around a specific word in C# webbrowser

开发者 https://www.devze.com 2023-01-27 16:25 出处:网络
How to linkify a specific word in C# webbrowser on OnDocumentComplete event. I want to linkfy all the words say \'hemant\' to hemant appears in the document in my c# browser. How to just add the ancho

How to linkify a specific word in C# webbrowser on OnDocumentComplete event. I want to linkfy all the words say 'hemant' to hemant appears in the document in my c# browser. How to just add the anchor ta开发者_JAVA百科g around any specific word using onDocumentComplete event?


You need to grab the HtmlDocument from the browser control and iterate the DOM and modify it.

Examples on using HtmlDocument can be found at MSDN.

For iterating all elements check out the All property. For each HtmlElement check innerText or innerHTML for your word, and change accordingly to wrap it with an anchor.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号