单击 iFrame 内的元素
我的内置浏览器下载了一个页面。
在此页面的“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
My built-in browser downloaded a page.
On this page under "body", there is an "iframe" tag.
Inside of this iframe, there is another code (div tags, table etc).
But I don't know how to access them.
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
I ran out of options.
I need to click a thing that is deep inside of this frame:
body -> div -> div -> div -> form -> div -> div -> div -> div -> div -> div -> div -> div -> table -> tbody -> tr -> td -> a
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
做
Document.InvokeScript([无论您要单击什么]
工作吗?
您确定已全部下载吗?Webbrowser.ReadyState 会为每一帧触发 Ready。
Does
Document.InvokeScript([whatever it is you want to click]
Work?
Are you sure that its all downloaded? Webbrowser.ReadyState triggers Ready for every frame.
您应该加载 iframe 中出现的页面,而不是加载父页面并浏览它。您可以获取 iframe 的 src 属性并导航到该页面。这样你就可以轻松访问你需要访问的节点。
Instead of loading the parent page and going through it, you should load the page which appears within iframe. You can get src attribute of iframe and navigate to the page. This way you can easily access nodes you need to access.