点击iFrame里面的元素

时间:2011-11-03 20:25:37

标签: c# html browser webbrowser-control

我的内置浏览器下载了一个页面 在“body”下的这个页面上,有一个“iframe”标签 在这个iframe中,还有另一个代码(div标签,表等) 但我不知道如何访问它们。

webBrowser1.Document.GetElementById("myiFrame").innerHTML // gives out empty result as if there is nothing there.
webBrowser1.Document.GetElementById("myiFrame").FirstChild.innerHTML // gives an error as if there is no first child.
webBrowser1.Document.GetElementById("mylink") // error as if it doesn't exist
webBrowser1.Document.GetElementsByTagName("a")[2] // error as if it doesn't eist

我的选项用完了。

我需要点击此框架内部的内容:

body -> div -> div -> div -> form -> div -> div -> div -> div -> div -> div -> div -> div -> table -> tbody -> tr -> td -> a

2 个答案:

答案 0 :(得分:0)

是否    Document.InvokeScript([whatever it is you want to click]

工作?

你确定全部下载了吗? Webbrowser.ReadyState触发每帧的准备就绪。

答案 1 :(得分:0)

您应该加载iframe中显示的页面,而不是加载父页面并通过它。您可以获取iframe的src属性并导航到该页面。这样您就可以轻松访问需要访问的节点。

相关问题