![](/img/trans.png)
[英]changing background color of webbrowser control, using c# code, does not work on windows 10
[英]c# webBrowser does not work with Iframes
我的應用程序中有一個webBrowser,帶有一個狀態欄,該狀態欄在以下情況下顯示鏈接地址:
將鼠標懸停在以下代碼上:
lbl1.Text = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition).GetAttribute("href");
但不適用於iframe。 我應該做什么? 謝謝。
我找到。 我必須更改此:
lbl1.Text = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition).GetAttribute("href");
到此編輯行:
lbl1.Text = (sender as HtmlDocument).GetElementFromPoint(e.ClientMousePosition).GetAttribute("href")
這是完整的代碼塊:
void Document_MouseOver(object sender, HtmlElementEventArgs e)
{
lbl1.Text = (sender as HtmlDocument).GetElementFromPoint(e.ClientMousePosition).GetAttribute("href");
}
然后在您要應用於WebBrowser的位置添加此阻止代碼
string html = string.Empty;
foreach (HtmlWindow frame in webBrowser1.Document.Window.Frames)
{
frame.Document.MouseUp+=new HtmlElementEventHandler(Document_MouseUp);
frame.Document.MouseOver+=new HtmlElementEventHandler(Document_MouseOver);
}
}
添加頁面中所有框架的事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.