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