HtmlWindow.Frames Свойство
Определение
Получает ссылку на каждый из элементов FRAME
, определенных на веб-странице.Gets a reference to each of the FRAME
elements defined within the Web page.
public:
property System::Windows::Forms::HtmlWindowCollection ^ Frames { System::Windows::Forms::HtmlWindowCollection ^ get(); };
public System.Windows.Forms.HtmlWindowCollection Frames { get; }
member this.Frames : System.Windows.Forms.HtmlWindowCollection
Public ReadOnly Property Frames As HtmlWindowCollection
Значение свойства
Объект HtmlWindowCollection фрейма
документа и объекты IFRAME
.An HtmlWindowCollection of a document's FRAME
and IFRAME
objects.
Примеры
В следующем примере кода изучаются все документы на странице, содержащей кадры, и создается таблица всех исходящих гиперссылок из каждой страницы для последующей проверки.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");
}
}
}
else
{
Hashtable docLinksHash = new Hashtable();
linksTable.Add(webBrowser1.Document.Url.ToString(), docLinksHash);
foreach (HtmlElement hrefElement in webBrowser1.Document.Links)
{
docLinksHash.Add(hrefElement.GetAttribute("HREF"), "Url");
}
}
}
}
Dim LinksTable As Hashtable
Private Sub GetLinksFromFrames()
LinksTable = New Hashtable()
Dim FrameUrl As String
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
Dim CurrentWindow As HtmlWindow = .Window
If (CurrentWindow.Frames.Count > 0) Then
For Each Frame As HtmlWindow In CurrentWindow.Frames
FrameUrl = Frame.Url.ToString()
Dim FrameLinksHash As New Hashtable()
LinksTable.Add(FrameUrl, FrameLinksHash)
For Each HrefElement As HtmlElement In Frame.Document.Links
FrameLinksHash.Add(HrefElement.GetAttribute("HREF"), "Url")
Next
Next
Else
Dim DocLinksHash As New Hashtable()
LinksTable.Add(.Url.ToString(), DocLinksHash)
For Each HrefElement As HtmlElement In .Links
DocLinksHash.Add(HrefElement.GetAttribute("HREF"), "Url")
Next
End If
End With
End If
End Sub
Комментарии
FRAME
— Это набор окон, определенных в FRAMESET
.A FRAME
is a set of windows defined within a FRAMESET
. FRAME
Включение размещения нескольких документов в одном документе.FRAME
s enable hosting multiple documents within a single document. Каждый из них FRAME
имеет определенную ширину строки и столбца и является позицией на странице по отношению к другим параметрам, FRAME
заданным в FRAMESET
; позиции объекта FRAME
является фиксированной, хотя пользователь иногда может использовать курсор мыши для увеличения или уменьшения FRAME
.Each FRAME
is defined as possessing a certain row and column width, and is position on the page in relation to the other FRAME
s 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
. Объект IFRAME
похож на кадр, но его не нужно закрепить в фиксированной положении.An IFRAME
is similar to a frame, but it need not be anchored in a fixed position.
Кадры будут содержать один экземпляр HtmlWindow для каждого FRAME
или, IFRAME
определенный в веб-странице.Frames will contain one instance of HtmlWindow for each FRAME
or IFRAME
defined within a Web page.