C#的WebBrowser操作frame實(shí)例解析
本文實(shí)例講述了用WebBrowser操作frame和iframe的方法,比較適合C#初學(xué)者參考學(xué)習(xí)。示例淺顯易懂,具體方法如下:
1.獲取frame的源文件
MessageBox.Show(webBrowser1.Document.Window.Frames["main"].Document.Body.InnerHtml);
2.獲取frame的HTMLDocument接口
HTMLDocument doc = (HTMLDocument)webBrowser1.Document.DomDocument; object j; for (int i = 0; i < doc.parentWindow.frames.length; i++) { j = i; HTMLWindow2Class frame = doc.parentWindow.frames.item(ref j) as HTMLWindow2Class; if (frame.name == "main") { MessageBox.Show(frame.document.title); } }
3.獲取frame的IHTMLDocument2接口
IHTMLDocument2 doc = (IHTMLDocument2)webBrowser1.Document.Window.Frames["main"].Document.DomDocument;
4.取得frame中被點(diǎn)擊的連接
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { string url = webBrowser1.Document.Window.Frames["main"].Document.ActiveElement.GetAttribute("src"); }
希望本文所述實(shí)例對大家的C#學(xué)習(xí)能起到一定的幫助作用。
- C#之WinForm WebBrowser實(shí)用技巧匯總
- 淺析c#中WebBrowser控件的使用方法
- 解決C#中WebBrowser的DocumentCompleted事件不執(zhí)行的實(shí)現(xiàn)方法
- 在C#中 webbrowser的使用心得
- C#的WebBrowser的操作與注意事項(xiàng)介紹
- 使用C#處理WebBrowser控件在不同域名中的跨域問題
- webBrowser代理設(shè)置c#代碼
- c# 在WebBrowser中用SendMessage模擬鼠標(biāo)點(diǎn)擊
- 使用C# 的webBrowser寫模擬器時的javascript腳本調(diào)用問題
相關(guān)文章
Unity3D游戲開發(fā)數(shù)據(jù)持久化PlayerPrefs的用法詳解
在本篇文章里小編給大家整理了關(guān)于Unity3D游戲開發(fā)之?dāng)?shù)據(jù)持久化PlayerPrefs的使用的相關(guān)知識點(diǎn)內(nèi)容,需要的朋友們參考下。2019-08-08UnityShader3實(shí)現(xiàn)轉(zhuǎn)圈與冷卻效果
這篇文章主要為大家詳細(xì)介紹了UnityShader3實(shí)現(xiàn)轉(zhuǎn)圈與冷卻效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-03-03Unity實(shí)現(xiàn)角色受擊身體邊緣發(fā)光特效
這篇文章主要為大家詳細(xì)介紹了Unity實(shí)現(xiàn)角色受擊身體邊緣發(fā)光特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-04-04