edge browser executejavascript method

ywin

New member
Local time
Today, 21:46
Joined
Sep 16, 2020
Messages
4
jsCode = "document.querySelector(""#form_arap_bxbusitem\\&childform2 > div > div > div.vat_amount.js-type-number.form-item > div.form-item-control > div > span > div > div > div > div > input"").value = 8888"

me.edgebrowser.executejavascript(jscode)

executed successfully in chrome devtools console,but failed in vba

web page with frames
 
executed successfully in chrome devtools console,but failed in vba
It is very easy to succeed running code using chrome devtools. In the case of a browser control, it is different because you have to account for both, the events that run within Access and the events that occur inside the browser.

It appears you're working with an input, so why don't you use instead:
"document.getElementsByTagName("input")(x).value = 8888"
Where x is a number that you have to find, since that could be a form, there may be a bunch of inputs. Simply go from 0 to n until you find the right input. This is NOT how I would do it, but it's a solution for something I can't see.
 
document.getElementsByTagName("input")(x).value = 8888"
report error: is not function
 
document.getElementsByTagName("input")(x).value = 8888
Since it's JS, it requires square brackets, my bad. Also, you don't use x, you use a number. Told you to check which number it was by trial and error, for example, with 1:
document.getElementsByTagName("input")[1].value = 8888
 
捕获.PNG

document.getElementsByTagName("input")[3].value = 88, executed in devtools console under mainiframe context successfullly
but failed in vba executejavascript.
 
the code below failed in vba executejavascript either.

var iframe1 = document.getElementById('mainiframe');
if (iframe1 && iframe1.contentWindow && iframe1.contentDocument) {
var inputElement = iframe1.contentDocument.querySelector('#form_head > div > div > div.zy.js-type-refer.form-item > div.form-item-control > div > span > div > div > div.wui-col-xs-12.wui-col.wui-col-xs-12.refer.clearfix.false.refer-input-common > div > ul > li.selected-input > div > input');
if (inputElement) {
inputElement.value = 'Hello from iframer';
console.log('Input value set successfully.');
} else {
console.error('Input element not found.');
}
} else {
console.error('Unable to access the iframe or its document.');
}
 
document.getElementsByTagName("input")[3].value = 88, executed in devtools console under mainiframe context successfullly
but failed in vba executejavascript.
I don't have access to the edge browser control, so I'm not sure how you can approach this. In the old browser, I would simply use the browser's API and do this:
myOldWebBrowserControl.Object.Document.getElementsByTagName("input")(3) = 88
I think you don't have the Object part of that reference. So, perhaps, you could simply use
myOldWebBrowserControl.Document.getElementsByTagName("input")(3) = 88
But only after making sure the website is fully loaded.
 

Users who are viewing this thread

Back
Top Bottom