HtmlWindow.WindowFrameElement 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得對應此視窗的框架元素。
public:
property System::Windows::Forms::HtmlElement ^ WindowFrameElement { System::Windows::Forms::HtmlElement ^ get(); };
public System.Windows.Forms.HtmlElement WindowFrameElement { get; }
public System.Windows.Forms.HtmlElement? WindowFrameElement { get; }
member this.WindowFrameElement : System.Windows.Forms.HtmlElement
Public ReadOnly Property WindowFrameElement As HtmlElement
屬性值
對 HtmlElement 應於此視窗元素 FRAME 。 如果這個視窗不是框架,則返回 null。
範例
以下程式碼範例比較 SRC 了 a FRAMESET 中框架的屬性與當前位置。 如果不同,框架會重置回原本的網址。
private void ResetFrames()
{
if (!(webBrowser1.Document == null))
{
HtmlElement frameElement = null;
HtmlWindow docWindow = webBrowser1.Document.Window;
foreach (HtmlWindow frameWindow in docWindow.Frames)
{
frameElement = frameWindow.WindowFrameElement;
String originalUrl = frameElement.GetAttribute("SRC");
if (!originalUrl.Equals(frameWindow.Url.ToString()))
{
frameWindow.Navigate(new Uri(originalUrl));
}
}
}
}
Private Sub ResetFrames()
If (WebBrowser1.Document IsNot Nothing) Then
Dim FrameElement As HtmlElement
Dim DocWindow As HtmlWindow = WebBrowser1.Document.Window
For Each FrameWindow As HtmlWindow In DocWindow.Frames
FrameElement = FrameWindow.WindowFrameElement
Dim OriginalUrl As String = FrameElement.GetAttribute("SRC")
If (Not OriginalUrl.Equals(FrameWindow.Url.ToString())) Then
FrameWindow.Navigate(New Uri(OriginalUrl))
End If
Next
End If
End Sub
備註
當你從FRAME集合中取得元素Frames時,會回傳一個 HtmlWindow。 如果你需要存取底層WindowFrameElement元素的屬性,例如屬性,FRAME請呼叫SRC這個物件。