我想在 HTML 文档中识别 Iframe 是否已加载。
这是我尝试过的,但我不确定这是否是识别 IFrame 加载的正确方法:
var myhtmlDocument = (IHTMLDocument2) HtmlDocument.DomDocument;
IHTMLSelectionObject htmlselectionObject = myhtmlDocument.selection;
bool frameloaded = false;
if (htmlselectionObject != null)
{
FramesCollection frames = myhtmlDocument.frames;
IHTMLSelectionObject frameSelection = frame.document.selection;
for (int i = 0; i < frames.length; i++)
{
object index = i;
IHTMLWindow2 frame = (IHTMLWindow2) frames.item(ref index);
IHTMLSelectionObject frameSelection = frame.document.selection;
if(frameSelection)
frameloaded = true;
}
}