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

示例

下面的代码示例将 SRCFRAMESET 帧的属性与当前位置进行比较。 如果它们不同,则帧将重置为其原始 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

注解

从集合中Frames检索FRAME元素时,它将返回 。HtmlWindow 如果需要访问基础FRAME元素的属性(如 SRC 特性),请对此对象调用WindowFrameElement

适用于

另请参阅