2012-03-22 55 views

回答

0

不,它不。我曾嘗試下一個:

DocumentText:

File.WriteAllText(@"C:\doc.txt", webBrowser1.DocumentText, Encoding.UTF8); 

的getElementsByTagName( 「HTML」)

HtmlElement elem; 
if (webBrowser1.Document != null) 
{ 
    HtmlElementCollection elems = webBrowser1.Document.GetElementsByTagName("HTML"); 
    if (elems.Count == 1) 
    { 
     elem = elems[0]; 
     string pageSource = elem.OuterHtml; 
     File.WriteAllText(@"C:\doc.txt", pageSource, Encoding.UTF8); 
    } 
} 

IOleCommandTarget

public void ShowSource() 
{ 
    IOleCommandTarget cmdt = null; 
    object o = null; 
    object oIE = null; 
    try { 
      cmdt = (IOleCommandTarget)this.Document.DomDocument; 
      cmdt.Exec(cmdGUID, oCommands.ViewSource, 1, o, o); 
    } catch (Exception ex) { 
      throw new Exception(ex.Message.ToString(), ex.InnerException); 
    } finally { 
      cmdt = null; 
    } 
} 

的唯一方法是要經過所有框架文件。

更新如果iframe中具有不同的URL,你會得到UnauthorizedAccessException when trying to retrieve iframe document

相關問題