HtmlWindow.WindowFrameElement Property

Definition

Gets the frame element corresponding to this window.

C#
public System.Windows.Forms.HtmlElement WindowFrameElement { get; }
C#
public System.Windows.Forms.HtmlElement? WindowFrameElement { get; }

Property Value

An HtmlElement corresponding to this window's FRAME element. If this window is not a frame, it returns null.

Examples

The following code example compares the SRC attribute of frames in a FRAMESET to the current location. If they are different, the frames are reset to their original URLs.

C#
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));
            }
        }
    }
}

Remarks

When you retrieve a FRAME element from the Frames collection, it returns an HtmlWindow. Call WindowFrameElement on this object if you need to access attributes of the underlying FRAME element, such as the SRC attribute.

Applies to

Produkt Versioner
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also