HtmlWindow.WindowFrameElement 屬性

定義

取得對應到這個視窗的框架項目。

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 中的 FRAMESET 畫面格屬性與目前位置進行比較。 如果兩者不同,框架會重設為其原始 URL。

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

備註

當您從集合擷 FramesFRAME 專案時,它會傳 HtmlWindow 回 。 WindowFrameElement如果您需要存取基礎 FRAME 元素的屬性,例如 SRC 屬性,請呼叫這個物件。

適用於

另請參閱