我正在自動填寫網站的過程中。使用Excel宏,一旦我登錄到網站,在所需的文本框中插入一個值,然後單擊該按鈕,網站消息框就會出現一條提示,要求我確認 - 您確定要更新該值嗎?使用VBA Excel自動運行InternetExplorer的網站消息框
宏的執行停止在該級別,導致不再執行該宏。
在搜索解決方案時,我發現一個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();
});