我正在自动化一个过程,以填补一个网站。使用Excel宏时,一旦我登录网站,在所需的文本框中插入一个值,然后单击按钮,一个网站消息框就会弹出一个警告,要求我确认-您确定要更新值吗?
宏的执行将在该级别停止,从而不会进一步执行宏。
在寻找解决方案时,我发现一个JavaScript函数,即确认消息框后执行的函数,应该从宏调用,而不是单击网页上的原始按钮。
我希望在编写代码来调用Excel宏中的JavaScript函数方面有帮助。
以下是来自该网页的查看源页的HTML代码。
$('#reloadButton').click(function () {
$(this).text(
$(this).attr('name')
).attr('disabled', 'disabled');
window.location.href = window.location.href.replace(/#.*$/, '');
});
SignalConsumer = function () {};
SignalConsumer.prototype = new TraderSettingsTool();
SignalConsumer.prototype.mySummaryPage = 'https://kvinvest.com/month/?action=template&tid=my_status';
SignalConsumer.prototype.isShowWaiver = 0;
SignalConsumer.prototype.amountPrecision = 1;
SignalConsumer.prototype._elements = {
"trading": {
"popup": $('#ssc-trading-popup'),
"amount": $('#ssc-trading-amount'),
"trade": $('#ssc-trading-trade'),
"provides": $('#ssc-trading-provides')
},
"slippage": {
"popup": $('#ssc-slippage-popup')
},
"provider": {
"popup": $('#ssc-provider-popup')
},
"consumers":{
"holder": $('#ssc-consumers-holder'),
"template": $('#ssc-consumers-template'),
"form": $('#ssc-consumers-form')
},
"subscribe": {
"server": $('#ssc-subscribe-server'),
"apply": $('#ssc-subscribe-apply'),
"loader": $('#ssc-subscribe-loader'),
"info": $('#ssc-subscribe-info'),
"form": $('#ssc-subscribe-form'),
"description": $('#ssc-subscribe-description')
},
"activate": {
"form": $('#ssc-activate-form'),
"slippage": $('#ssc-activate-slippage'),
"amount": $('#ssc-activate-amount'),
"popup": $('#ssc-activate-popup'),
"apply": $('#ssc-activate-apply'),
"cancel": $('#ssc-activate-cancel'),
"agree": $('#ssc-activate-agree'),
"sll": $('#ssc-activate-sll-value'),
"loader": $('#ssc-activate-sll-loader'),
"redirect": $('#ssc-activate-redirect')
},
"waiver": {
"popup": $('#ssc-waiver-popup'),
"agree": $('#ssc-waiver-agree'),
"apply": $('#ssc-waiver-apply'),
"subscribe": $('#ssc-waiver-subscribe')
},
"history": {
"log": $('#ssc-history-log')
}
};
SignalConsumer.prototype.bindEvents = function () {
var self = this;
this._elements.subscribe.form.find('form').submit(function () {
return false;
});
// I THINK BELOW IS THE MESSAGE BOX POP UP
this._elements.subscribe.apply.click(function () {
if(!confirm('Are you sure to update?')){
return false;
}
self.subscribeToServer();
return false;
});
// On show history popup
this._elements.history.log.click(function () {
self.loadHistoryLog();
return false;
});
// --- ACTIVATION LOGIC ---
this._elements.activate.apply.click(function () {
self.applyActivateServer();
return false;
});
this._elements.activate.agree.change(function () {
var disabled = $(this).is(':checked') ? '' : 'disabled';
self._elements.activate.apply.attr('disabled', disabled);
});
this._elements.activate.cancel.click(function () {
self.hidePopUp();
return false;
});
this._elements.activate.redirect.click(function () {
self.hidePopUp();
});
发布于 2013-10-17 18:18:39
在这个答案中,我不会提供您所请求的代码。
这个答案更像是一个建议,因为我不能完全确定你要做的是什么,以及你建议的技术方法是否是你真正想要的。
对我来说,将VBA引擎与web客户端连接起来没有多大意义,除非您的目标是仅检索数据-例如web查询。
如果要在VBA引擎和web应用程序之间创建交互式数据流,使用连接到数据库系统的服务器端脚本(用PHP或ASP编写)创建连接似乎更符合逻辑(或者如果您希望将值存储在临时会话变量中)。
用户输入一个值,然后单击一个按钮,这一事实表明您希望构建特定的计算逻辑。这通常是在服务器上完成的,而不是在浏览器级别。
Javascript/jQuery -> PHP/ASP -> VBA
如果这对你有任何意义的话。
https://stackoverflow.com/questions/19418732
复制相似问题