我在网站上有这三个框架。
<frame scrolling="AUTO" src="../../vix/thalada/Rangasamy?MokkaKumuta1234567" name="AAN">
<frame scrolling="AUTO" src="../../vix/thalada/Rangasamy?MokkaK****13245678" name="BAN">
<frame scrolling="AUTO" src="../../vix/thalada/Rangasamy?MokkaK****85234175" name="CAN">
这是怎么回事:
Set oIE = CreateObject("InternetExplorer.application")
oIE.Visible = True
oIE.navigate ("https://ec.rcuwebportal.au.eds.com/cics/r1cb/rm0p00ba?cb246")
oIE.Document.getElementsByTagName("a").item(0).Click // This works and it clicks on a image button in the frame named AAN. Fine
接下来,当我尝试访问名为BAN的帧中存在的另一个文本框时,我得到了找不到对象的错误。显而易见,因为我仍然是框架AAN,但该元素属于框架BAN。
以下是名为BAN的框架中出现的文本框。
<input type="text" maxlength="30" size="30" value=" " name="BAFREENAME"></input>
如何访问此框架上的表单控件?有任何想法吗? 感谢您的帮助。
答案 0 :(得分:0)
您可以先访问帧的所有元素,遍历帧,然后引用它们的contentWindow.document
。
Dim oIE, aHTML, oIFrames, frame, i, obj, ifHTML: i = 1
Set oIE = CreateObject("InternetExplorer.application")
oIE.Visible = True
'This page must be remote...
oIE.navigate ("http://your/website...")
'local websites (file://) will return access denied on IFRAME/Frame Content viewing.
Do
Loop While oIE.ReadyState < 4 And oIE.Busy
Set aHTML = oIE.document
Set iframes = aHTML.getElementsByTagName("frame")
For Each frame In iframes
Set inputs = frame.contentwindow.document.getElementsByTagName("input")
For Each obj In inputs
If obj.className = "BAFREENAME" Then
'MsgBox "found BAFREENAME in frame:" & i
End If
Next
i = i + 1
Next
'MsgBox "done"