【问题标题】:Access form elements on different Frames in VBScript在 VBScript 中访问不同框架上的表单元素
【发布时间】:2014-04-28 14:31:49
【问题描述】:

我在一个网站上有这三个框架。

<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 的框架中存在的另一个文本框时,我收到了 object not found 错误。很明显,因为我仍然是框架 AAN ,但元素属于框架 BAN。

下面是显示在名为 BAN 的框架中的文本框。

<input type="text" maxlength="30" size="30" value=" " name="BAFREENAME"></input>

如何访问此框架上的表单控件?有任何想法吗? 感谢您的帮助。

【问题讨论】:

    标签: forms iframe vbscript frame frameset


    【解决方案1】:

    您可以访问框架外的所有元素,首先遍历框架,然后引用它们的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"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      • 2015-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多