0
在wpf webbrowser控件中的動作href鏈接我使用wpf webbrowser控件通過WebBrowser.NavigateToString()方法顯示手動生成的html代碼。在這個網站碼有很多手工環節,如下面的例子:通過代碼
<a href="#marker_1">Go to Mark 1</a>
當我點擊html文檔瀏覽器THR跳轉到它這個鏈接。它工作正常。我想要的是通過C#代碼跳轉到標記。我知道WebBrowser.Document屬性是一個來自Microsoft.mshtml.dll的IHtmlDocument。我通過所有IHtmlAncorElements將它變成了一個enumarte。我通過名稱找到Ancor並將其重新轉換爲IHtmlElement。所以,我有IHtmlElement對象,但我不不,我怎麼能是陽離子也一樣的鏈接在此模擬代碼:
var ancorElement = ((IHtmlDocument)WebBrowser.Document).all.Cast<IHtmlElement>().Where(element => elment is IHtmlAncorElement).FirstOrDefault(element => element.href.equals("#marker_1"));
if (ancorElement != null) /* so i don't know the right way */ ancorElement.Click() or ancorElement.Action()
所以我希望任何知道一種方式來運行通過C#代碼的鏈接!
問候
丹尼爾
你好喬希,對不起,我的英文不太好,所以我希望你能理解一點。我想要的是跳轉到我生成的代碼在C#中的任何部分。當我使用點擊 link in the code via webbrowser the it jump automaticly to the part. The same procedure i want to do via code. I have a list with id strings var ids = new List{"#id_1","#_id2"}. Then i want the browser say "WebBrowser jump to part with id_1" in equals when i click in a webbrowser on the link To Part 2! –
Lutze
2014-09-02 07:09:34