vba在网页中跳过弹出消息框 [英] vba skip popup message box in webpage
问题描述
我的代码
DIM HTMLdoc作为MSHTML .HTMLDocument
'提交数据但卡在弹出消息框
HTMLdoc.all.Item
调用HTMLdoc.parentWindow.execScript(licitarLeilao();,JScript )
WEBPAGE
...
函数licitarLeilao(){
var ultimaLicitacao = document.getElementById('ultimaLicitacao')。
var valorLicitar = document.getElementById('valorLicitar')。
if(ultimaLicitacao ==' - '){
ultimaLicitacao = document.getElementById('valorBase')。
}
var racio = toNum(valorLicitar)/ toNum(ultimaLicitacao);
if(racio< 1.5){
if(!confirm('Confirma o valor delicitação('+ valorLicitar +'eur。)doleilão?')){
返回false;
}
}
else {
if(!confirm('ATENÇÃO!! O valor delicitaçãoémuito superioràúltimalicitação。\\\
\\\
Confirma o valor de licitação('+ valorLicitar +'eur。)doleilão?')){
return false;
}
}
var flow = document.getElementById('flow');
flow.value ='8';
document.formulario.submit();
}
您可以尝试覆写 window.confirm
具有不同的功能:
使用HTMLdoc.parentWindow
.execScriptwindow.confirm = function(){return true;};,JScript
.execScriptlicitarLeilao();,JScript
End with
在为我工作的测试页面中。
注意:如果网页上有其他代码使用确认
,那么该代码的功能可能会受到影响。
I’m a beginner and desperately seeking for help. I would kindly request your support and apologize in advance for the poor wording and eventual lack of info (again, I’m a rookie). I’m building an Excel macro to fill in a (private) webpage and after filling in the requested data, I’m also able to call the javascript function that submits the data/form. However, it appears a "Message from webpage" that I’m unable to confirm (always "ok"/enter) or simple skip. The Macro just stops and I can’t do anything without clicking manually in the "ok" button. I’ve spend several hours searching and trying different solutions but nothing seems to work, probably due to my poor skills. Hereunder I send the code that is beating me hard (hope is enough). Looking forward for your help
MY CODE
DIM HTMLdoc As MSHTML.HTMLDocument
' Submits data but gets stuck in the popup message box
HTMLdoc.all.Item
Call HTMLdoc.parentWindow.execScript("licitarLeilao();", "JScript")
WEBPAGE
...
function licitarLeilao(){
var ultimaLicitacao = document.getElementById('ultimaLicitacao').value;
var valorLicitar = document.getElementById('valorLicitar').value;
if(ultimaLicitacao == ' -- '){
ultimaLicitacao = document.getElementById('valorBase').value;
}
var racio = toNum(valorLicitar) / toNum(ultimaLicitacao);
if (racio < 1.5) {
if(!confirm('Confirma o valor de licitação (' + valorLicitar +' eur.) do leilão?')){
return false;
}
}
else {
if(!confirm('ATENÇÃO!! O valor de licitação é muito superior à última licitação. \n\n Confirma o valor de licitação (' + valorLicitar +' eur.) do leilão?')){
return false;
}
}
var flow = document.getElementById('flow');
flow.value = '8';
document.formulario.submit();
}
You can try overwriting window.confirm
with a different functionality:
With HTMLdoc.parentWindow
.execScript "window.confirm = function(){return true;};", "JScript"
.execScript "licitarLeilao();", "JScript"
End With
In a test page that worked OK for me.
NOTE: if there's any other code on the web page which uses confirm
then the functionality of that code may be impacted.
这篇关于vba在网页中跳过弹出消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!