如何在c#中访问iFrame的html内容? [英] How do I access a html content of an iFrame in c#?

查看:273
本文介绍了如何在c#中访问iFrame的html内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问iframe中的html元素,但它不起作用。





I am trying to access the html element inside an iframe but it doesnt work.


HtmlWindow hwMain = webBrowser1.Document.Window.Frames[0];
            HtmlElementCollection eleCaptcha = hwMain.Document.GetElementsByTagName("iframe");

            foreach (HtmlElement he in eleCaptcha)
            {
                if (he.GetAttribute("name").Equals("VerifyimageFrame"))
                {
                    writeLogs(he.OuterHtml != null ? he.OuterHtml.ToString() : "Can't Find Element!");
                    he.Focus();
                    //Clipboard.SetImage(he);
                    HtmlElementCollection o = he.Document.Body.GetElementsByTagName("img");
                    foreach (HtmlElement he1 in o)
                    {
                        if (he1.GetAttribute("title").Equals("Refresh verification code"))
                        {
                            writeLogs(he1.OuterHtml != null ? he1.OuterHtml.ToString() : "Can't Find Element!");

                        }
                        else
                        {
                            MessageBox.Show("null");
                        }
                    }

推荐答案

制作IFrame Runat服务器



试试这个



http://stackoverflow.com/questions/1277776/changing-an-iframes-innerhtml-from-codebehind [ ^ ]



http://stackoverflow.com/questions/3945176/talking-to-iframe-from-asp-net -code-behind [ ^ ]
Make IFrame Runat Server

try this

http://stackoverflow.com/questions/1277776/changing-an-iframes-innerhtml-from-codebehind[^]

http://stackoverflow.com/questions/3945176/talking-to-iframe-from-asp-net-code-behind[^]


HTTP ://www.htmlgoodies.com/beyond/css/filtering-iframe-content-using-jquery.html [ ^ ]


这篇关于如何在c#中访问iFrame的html内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆