mshtml.FramesCollection frames = doc.frames;
                try
                {
                    for (int i = 0; i < frames.length; i++)
                    {
                        object oIndex = (object)i;
                        System.Type type = frames.item(ref   oIndex).GetType();
                        mshtml.HTMLWindow2Class frame = (mshtml.HTMLWindow2Class)frames.item(ref   oIndex);
                        IHTMLDocument2 frameDoc = (IHTMLDocument2)frame.document;
                        // string frameText = frameDoc.body.innerText;
                        MessageBox.Show(frameDoc.url);
                    }
                }
                catch (Exception e1)
                {
                    MessageBox.Show(e1.ToString());
                }------------------------------------------------------
System.UnauthorizedAccessException: 拒绝访问。   在 System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)   在 mshtml.HTMLWindow2Class.get_document()
希望大家帮忙给看看
谢谢了
我想获取iframe中的网页内容
不知道有什么好的办法

解决方案 »

  1.   

    HTMLDocument mydoc = (HTMLDocument)axWebBrowser1.Document;
    mshtml.IHTMLWindow2 myWin = mydoc.parentWindow;
    mshtml.FramesCollection myFrameC = myWin.frames;
    int CountFrames = myFrameC .length;
    mshtml.IHTMLWindow2 GoWin;
    object x;
    for(int i = 0; i < CountFrames ; i++)
    {
        x = i;
        GoWin = (mshtml.IHTMLWindow2)oFrameC.item(ref x);
        //GoWin.document.body.outerHTML; //這行即可獲取iframe中的网页内容
    }
      

  2.   

    GoWin = (mshtml.IHTMLWindow2)oFrameC.item(ref x);
    改成
    GoWin = (mshtml.IHTMLWindow2)myFrameC.item(ref x);
      

  3.   

    还不行吗 
    ------------------------------------------------------
    System.UnauthorizedAccessException: 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))   在 mshtml.HTMLWindow2Class.IHTMLWindow2_get_document()   在 WindowsApplication1.frmWebBrowser.axWebBrowser1_DocumentComplete(Object sender, DWebBrowserEvents2_DocumentCompleteEvent e) 位置 C:\Documents and Settings\桌面\MultiTabWebBrowser_src\frmWebBrowser.cs:行号 934
    ---------------------------
    确定   
    ---------------------------
      

  4.   

    htmltext = webBrowser1.Document.Window.Frames["SI2_mem_index"].Document.Window.Frames["body"].Document.Window.Frames["body_browse"].Document;
                        srchtml = htmltext.Body.InnerHtml;这样可以试试
    不过使用webbrowser的