vba java 网页,通过VBA提交JSP网站的Java脚本表单

I need to fill the login form by VBA code.

I could not get any reaction on any combination of ".Click" method so i've tried to fill the form and then call JS submitting function but always get this error (as a VBA Error Message Box):

Could not complete the operation due to error 80020101

On the .jsp page there are following elements to interact with:

The form itself:

method="POST" name="LoginViewForm" action="LoginViewController.jsp">

Input boxes are the following:

tabindex="1" class="inputField" οnfοcus="this.select();">

type="password" tabindex="2" class="inputField"

οnfοcus="this.select();" autocomplete="off">

There is a button, which should be clicked to submit a form:

class="buttonBorderEmphasized">

tabindex="3">  

Login  

And there is following script function, which is started by the button above:

function submitLogin(form)

{

if(validateLogin()) {

window.document.body.style.cursor = 'progress';

showStatusMessage();

form.ControllerAction.value = 'Login';

form.submit();

return;

} else resetSubmitted(); return;

}

I'm trying following code to handle with it (have tried different variants of calling java script, this is final one, but still doesn't work):

Set objFormMain = IEDoc.Frames("i2ui_shell_content").Document _

.Frames("results").Document.forms("LoginViewForm")

With objFormMain

.Elements("LoginUser").Value = 1

.Elements("dspLoginPassword").Value = 1

IE.Document.all.Item

Call IE.Document.parentWindow.execScript("submitLogin(document.LoginViewForm)", "JavaScript")

.submit

End With

The error itself returns at line "Call IE.Document.parentWindow.execScript("submitLogin(document.LoginViewForm)", "JavaScript")"

Any ideas how to modify the code to make it work?

解决方案

Well, thanks everyone for concerns, I've found what I need.

Actually, I didn't need to address the script directly. I've just had to dig a bit deeper in trying to use .Click method.

Initially I supposed, that only some "button" tags may be accessed by ".Click", but then I found that you may use it on < a ...> tag as well.

So, i've just used following code:

IEDoc.Frames("i2ui_shell_content").Document.Frames("results") _

.Document.forms("LoginViewForm").GetElementsByTagName("a")(1).Click

Which accordingly run JS, contained in this tag:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值