This documentation is archived and is not being maintained.

HtmlWindow.Frames Property

Gets a reference to each of the FRAME elements defined within the Web page.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public HtmlWindowCollection Frames { get; }

Property Value

Type: System.Windows.Forms.HtmlWindowCollection
An HtmlWindowCollection of a document's FRAME and IFRAME objects.

A FRAME is a set of windows defined within a FRAMESET. FRAMEs enable hosting multiple documents within a single document. Each FRAME is defined as possessing a certain row and column width, and is position on the page in relation to the other FRAMEs defined within the FRAMESET; the position of a FRAME is fixed, although a user may sometimes use the mouse cursor to grow or shrink the FRAME. An IFRAME is similar to a frame, but it need not be anchored in a fixed position.

Frames will contain one instance of HtmlWindow for each FRAME or IFRAME defined within a Web page.

The following code example inspects each document within a page containing frames and creates a table of all of the outgoing hyperlinks from each page for future inspection.

		private void GetLinksFromFrames()
			Hashtable linksTable = new Hashtable();
			string frameUrl;

			if (!(webBrowser1.Document == null))
				HtmlWindow currentWindow = webBrowser1.Document.Window;
				if (currentWindow.Frames.Count > 0)
					foreach (HtmlWindow frame in currentWindow.Frames)
						frameUrl = frame.Url.ToString();
						Hashtable frameLinksHash = new Hashtable();

						linksTable.Add(frameUrl, frameLinksHash);
						foreach (HtmlElement hrefElement in frame.Document.Links)
							frameLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");
					Hashtable docLinksHash = new Hashtable();
					linksTable.Add(webBrowser1.Document.Url.ToString(), docLinksHash);

                    foreach (HtmlElement hrefElement in webBrowser1.Document.Links)
						docLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0