关闭JavaScript的提示使用VBA自动化 [英] Close JavaScript Alert Using VBA Automation

查看:206
本文介绍了关闭JavaScript的提示使用VBA自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方式来关闭一个Javascript弹出/消息框(即不是一个新的IE窗口,而是一个照本宣科的警报()),当加载网页加载。

I am searching for a way to close a Javascript pop-up/message box (i.e. not a NEW IE window, but a scripted alert()) that loads when a webpage is loaded.

我现在有code是将数据加载到一个搜索表单,运行搜索,检索结果所需要的信息,退出搜索,然后在列表中的下一个项目开始。在某些情况下,有一个片的关键信息从搜索结果中丢失。发生这种情况时,在页面上的JavaScript加载页面时,让用户知道这些信息丢失弹出消息。随着自动化code暂停(等待)为箱体继续前清除,用户必须确定按钮点击之前会出现这种情况。

I currently have code that loads data into a search form, runs the search, retrieves the needed information from the results, exits the search, then continues with the next item in a list. In some cases, there is a piece of critical information missing from the search results. When this happens, the JavaScript on the page pops up the message when the page loads, letting the user know that info is missing. With the automation the code halts(waits) for the box to clear before continuing, and the user must click on the OK button before this will happen.

(我也没办法直接更改页面的源脚本,因为这是我的责任范围之外的在这里工作另外,它保留此功能用于一般用途,更重要的,这将真正唯一的好处这个小-使用功能我创建。)

(I have no way to change the source script of the page directly, as that is outside of my scope of responsibility here at work. Plus, it is more important to retain this functionality for general use; it would really only benefit this small-usage function I'm creating.)

虽然我不能改变源脚本,我发现了一个例如< /一>如何prevent从通过改变加载脚本显示一个弹出/警报。但是,它涉及到一个已经加载的页面,并没有真正为我工作(据我可以告诉)。

While I can't change the source script, I have found an example of how to prevent a pop-up/alert from displaying by changing the loaded script. However, it relates to an already-loaded page and doesn't really work for me (as far as I can tell).

IE.Document.getElementById("clearRelItems").removeAttribute "onClick"
IE.Document.getElementById("clearRelItems").setAttribute "onClick", "return true;"

是否有可能使用这种方法来使的页面完全加载一改之前的?即可以这样用某种方式绕过/回避在页面加载函数调用?

Is it possible to use this method to make a change before the page has fully loaded? i.e. can this be used to somehow bypass/circumvent the function call at page load?

我知道的SendKeys,但我会preFER避免这个选项,如果在所有可能的(我可能最终会如果没有其他替代存在使用此选项)。此功能的目的是由用户发起的,则留在后台运行,因为它需要一定的时间才能完成。

I know about sendkeys, but I would prefer to avoid this option if at all possible (I may end up using this option if no other alternative exists). This function is intended to be initiated by the user, then left running in the background as it will take some time to complete.

我看着抢夺XML通过@Kyle的建议,但我不相信我有足够的熟练,使这种方法的工作。

I have looked into grabbing the XML as suggested by @Kyle, but I don't believe I am proficient enough to make this method work.

怎么回事,我可能避开警报?有没有办法真正激活警报的OK按钮?页面的警报/加载可以绕过任何其他方式?

How else might I get around the alert? Is there a way to actually activate the OK button on the alert? Can the alert/loading of the page be bypassed any other way?

推荐答案

一个解决方法可能会认识到,当你的脚本被卡住,然后只发送按键输入关闭弹出窗口。

One work-around could be to recognize when your script is stuck and then just send the keystroke "enter" to close the pop-up.

这篇关于关闭JavaScript的提示使用VBA自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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