【问题标题】:Button clicking blues (click js button from vbs)按钮单击蓝调(单击 vbs 中的 js 按钮)
【发布时间】:2015-03-03 20:51:41
【问题描述】:

就在我认为我可以处理任何按钮时,我遇到了一个对我尝试的任何操作都没有反应的按钮。这是我的代码的基本框架(非常基本)。只是尝试打开此页面并单击下一页按钮。

Set objWshShell = Wscript.CreateObject("Wscript.Shell")
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
IE.Navigate "http://centraloklahomaproperties.com/SiteContent/OKC/MemberSearchOKC.aspx"
Do Until IE.ReadyState = 4: WScript.sleep 100: Loop

On error resume next

Dim i
i = 0

Do while i < 5
i = i + 1

Do Until IE.ReadyState = 4: WScript.sleep 100: Loop

'Click button here!

Loop

我尝试过的事情:

1) IE.Navigate "javascript:open.document.getElementByID('btnRight').onclick;"

2) IE.Navigate "Javascript:window.opener.btnright.click();"

3) For Each btn In IE.Document.getElementsByTagName("img")
If btn.id = "btnRight" Then btn.Click()
Next

4) ie.navigate "javascript:InvokeScript('Next(1)');"

5) Browser.InvokeScript("Next(1)")

6) ie.Navigate( Uri("javascript:(function(){ Next(1); })();") )

7) Set oButton = IE.getElementById("btnRight")
oButton.Click()

这里也试过方法: How can I click a js button on VB

这里是按钮html:

<img width="30" height="28" id="btnRight" onmouseover="Tab(event)" onmouseout="Tab(event)" onclick="Next(1);" alt="Next" src="http://centraloklahomaproperties.com/SiteContent/OKC/images/icon_arrow_next-default.gif">

奇怪的是,除非我专门右键单击左框架并查看源代码,否则该框架甚至不存在。如果我只是在 IE 中打开页面并转到 >Edit>Source,它是不存在的。可能是我的问题的一部分。

【问题讨论】:

  • 图像不是按钮,但是您可以使用 onclick() 调用 onclick 处理程序。
  • 这听起来很有希望——正确的语法是什么?我想知道是否需要一些方法来定位左框架?

标签: javascript vbscript frame


【解决方案1】:

尝试改变:

Set IE = CreateObject("internetexplorer.application")

到

Set IE = WScript.CreateObject("InternetExplorer.Application","objIE_")

怎么样:

Set oButton = IE.getElementById("btnRight")
oButton.Click()

【讨论】:

  • 去掉on error resume next,如果有则粘贴错误。
  • 第 17 行/字符 1:对象不支持此属性或方法:'IE.getElementById'
  • 看起来源包含 iframe - 这会改变我应该接近它的方式吗?
  • 试过设置 IE = WScript.CreateObject("InternetExplorer.Application","objIE_"),同样的错误。您提出的解决方案对您有用吗?
  • 我刚试过。这是因为 iFrame。我加载了页面,将其放入文本文件中,按 ctrl+f 表示“btnRight”,但它不在其中。我不确定是否有一个好的解决方案。我会尝试一些事情。
猜你喜欢
  • 2013-06-23
  • 2016-01-30
  • 2011-06-16
  • 2020-07-28
  • 1970-01-01
  • 1970-01-01
  • 2017-08-30
  • 1970-01-01
  • 2016-11-19
相关资源
最近更新 更多