在VBScript中访问不同框架上的表单元素 [英] Access form elements on different Frames in VBScript

查看:181
本文介绍了在VBScript中访问不同框架上的表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < frame scrolling =AUTOsrc =../ ../vix/thalada/Rangasamy?MokkaKumuta1234567name =AAN> 

< frame scrolling =AUTOsrc =../../ vix / thalada / Rangasamy?MokkaK **** 13245678name =BAN>

< frame scrolling =AUTOsrc =../../ vix / thalada / Rangasamy?MokkaK **** 85234175name =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 it点击名为AAN的框架中的图像按钮。 Fine

接下来,当我尝试访问另一个存在于名为BAN的框架中的文本框时,该对象未找到错误。很明显,因为我仍然是框架AAN,但元素属于框架BAN。



以下是名为BAN的框架中的文本框。

 < input type =textmaxlength =30size =30value =name =BAFREENAME> < /输入> 

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

解决方案

您可以首先访问框架中的所有元素,然后引用它们的 contentWindow.document

  Dim oIE,aHTML,oIFrames,frame,i,obj,ifHTML:i = 1 
Set oIE = CreateObject (InternetExplorer.application)
oIE.Visible = True

'此页面必须是远程的...
oIE.navigate(http:// your / website。 ..)
'本地网站(file://)将返回IFRAME / Frame内容查看被拒绝的访问。




循环虽然oIE.ReadyState< 4和oIE.Busy

设置aHTML = oIE.document

设置iframes = aHTML.getElementsByTagName(frame)

For Each frame In iframes
Set inputs = frame.contentwindow.document.getElementsByTagName(input)
For Each obj In输入
如果obj.className =BAFREENAME则找到
'MsgBox BAFREENAME在框架中:& i
End If
Next
i = i + 1
Next
'MsgBoxdone


I have these three frames on a website.

<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">

This is how it goes:

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

Next when I tried to access another text box that is present in the frame named BAN , I got the object not found error. Obviousy, because I'm still the frame AAN , but the element belongs to frame BAN.

Below is the textbox that is present in the frame named BAN.

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

How do I access the form control on this frame? Any ideas? Appreciate your help.

解决方案

You can access all elements off of the frames by first, iterating through the frames, then referencing their 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"

这篇关于在VBScript中访问不同框架上的表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆