如何通过Excel VBA单击JavaScript确认弹出窗口

编程入门 行业动态 更新时间:2024-10-09 15:24:47
本文介绍了如何通过Excel VBA单击JavaScript确认弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用InternetExplorer对象与网页进行交互,填写表单以及所有内容。有时,单击页面上的按钮后,会弹出一个对话框,要求确认操作。如何单击弹出窗口中的确定按钮?

I am using the InternetExplorer object to interact with a web page, filling out a form and all that. At one point, after clicking a button on a page a Dialog box pops up asking to confirm the operation. How do I click the OK button in the popup?

相关的JavaScript和HTML为:

The relevant JavaScript and HTML is:

function CheckMakeCurr() { if(confirm('Are you sure you want to set the\n "Last Rebalance Date" to today?')) { return true; } else { return false; } };

...

<INPUT onclick="return CheckMakeCurr()" class=button type=submit value="Make Current" name=updaterebaldt>

Excel vba代码为:

The Excel vba code is:

Dim oInput As IHTMLInputElement ' Initialize oInput. ... ' Click oInput. oInput.click ' The confirm box comes up. What now?

推荐答案

在单击链接之前,请删除 onclick 处理程序,它会触发弹出窗口:

Before you click the link, remove the onclick handler which triggers the popup:

oInput.onclick = "" oInput.click

更多推荐

如何通过Excel VBA单击JavaScript确认弹出窗口

本文发布于:2023-11-27 16:16:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638712.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   弹出窗口   Excel   VBA   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!