这个问题听起来很愚蠢,但是为什么当我使用函数GetElementsByTagname("frame")时,它只返回3作为长度,而不是我期望的5?
这是HTML of the webpage ,我数到了标记名"frame“的5倍,但当我在VBA中询问长度时,得到的结果是3…
我的观察:
1)可以看到3是主帧(top_navigation,contentframe,dummyframe)的数量
2)如果我尝试通过getelementbyname访问其中一个主机,它可以工作,但如果我尝试访问contentframe的子帧( leftnavigation或postfachcontent),它不能工作(检测到0项)
下面是我的代码:
Dim Frame As IHTMLElementCollection
Set Frame = IEDoc.getElementsByName("contentframe") ' this works and returns 1 item
MsgBox Frame.Length
Set Frame = IEDoc.getElementsByName("postfachcontent")
MsgBox Frame.Length ' this returns 0 item
Dim Collection As IHTMLElementCollection
Set Collection = IEDoc.getElementsByTagName("frame")
MsgBox Collection.Length ' this returns 3 and I expected 5...发布于 2016-11-09 18:49:35
该页面上只有3个框架,其余的都在一个嵌入的html框架中,getElementsByTagName无法访问它,因为它是一个不同的DOM树。
https://stackoverflow.com/questions/40505114
复制相似问题