0
我嘗試在我的webbroser控件中查找對話框功能,它應該搜索幾個單詞(向前)並突出顯示它們。 我試圖從this MSDN questionWeb瀏覽器查找html元素中文本的對話框
private bool FindFirst(string text)
{
IHTMLDocument2 doc = (IHTMLDocument2)browserInstance.Document;
IHTMLSelectionObject sel = (IHTMLSelectionObject)doc.selection;
sel.empty(); // get an empty selection, so we start from the beginning
IHTMLTxtRange rng = (IHTMLTxtRange)sel.createRange();
if (rng.findText(text, 1000000000, 0))
{
rng.select();
return true;
}
return false;
}
下面的代碼但是這個代碼,並在原來問題的代碼搜索整個文檔,並使用range = body.createTextRange()
創建範圍,我想一個特定的元素中進行搜索(例如只中的文字div
)
我該怎麼做?