Share via

edge browser control executejavascript method

Anonymous
2024-06-19T05:36:34+00:00

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

Microsoft 365 and Office | Access | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2024-06-28T02:47:16+00:00

https://filetransfer.io/data-package/DoMYNUWt#link

thanks

用友的bip

Thanks for your feedback.

I have found two level iframes nested.

So in Access webview need grasp the element from the first level.

<script>

//<iframe id="forwardFrame" src="./新增_境内差旅费报销单_files/index.html" frameborder="0" height="100%" width="100%"></iframe>

///storage/emulated/0/Download/2/新增_境内差旅费报销单.html

//<iframe fieldid="main_iframe" id="mainiframe" class=" iframeIndex" frameborder="0" scrolling="0" src="./index(10).html" style="width: 100%; height: 100%;">

///storage/emulated/0/Download/2/新增_境内差旅费报销单_files/index.html

///storage/emulated/0/Download/2/新增_境内差旅费报销单_files/index(10).html

function myFunction() {

var elmnt = document.getElementById('forwardFrame'); 

 alert(elmnt.outerHTML)

var elmnt2 = elmnt.contentWindow.document.getElementsByTagName("iframe")[0];

 alert(elmnt2.outerHTML)

var elmnt3 = elmnt2.contentWindow.document.getElementsByTagName("input")[3];

elmnt3.value=888; 

}

// var elmnt3 = elmnt2.contentWindow.document.body;

 //alert(elmnt3.outerHTML)

/*

var elmnt = iframe.contentWindow.document.getElementsByTagName("input")[3]; 

alert(elmnt.outerHTML)

elmnt.value=888

*/

</script>

https://filetransfer.io/data-package/yS8d5EQq#link

js in VBA may like this.

jsCodes="var elmnt = document.getElementById('forwardFrame');

 alert(elmnt.outerHTML)

var elmnt2 = elmnt.contentWindow.document.getElementsByTagName(""iframe"")[0];

 alert(elmnt2.outerHTML)

var elmnt3 = elmnt2.contentWindow.document.getElementsByTagName(""input"")[3];

elmnt3.value=888; "

//单据日期

I have dissabled all css and js

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

21 additional answers

Sort by: Most helpful
  1. Anonymous
    2024-06-25T04:10:01+00:00

    floder 1 : open page

    floder 1: after clicking add new bottun, show popup page

    html file:https://1drv.ms/f/s!Am48J5c1efez5yY-yeuM5cP9s766?e=Sd6JfG

    I have almost no js knowledge,so,it is complicated for me to resolove this problem.

    i think best solution is waiting the opening of rest api.

    thanks for you help!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-06-24T11:44:50+00:00

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-06-24T11:35:36+00:00

    Sorry,What did you mean failed?

    No any detail?

    Have you dumped the error message by error events?

    Console only works in devtool.

    So you need use alert to pop up error rather than console.

    Have you tried below codes and not found any popup msgbox?

    Try dump error.

    jsCode = "window.addEventListener('error',function(e){

        alert(e.filename+'\nLine '+e.lineno+'\n'+e.message);
    
    });"
    

    me.edgebrowser.executejavascript(jscode)

    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)

    //end

    //this is another try

    var iframe = document.getElementById('mainiframe');

    var elmnt = iframe.contentWindow.document.getElementsByTagName("input")[3];

    alert(elmnt.innerHTML)

    //debug

    elmnt.value=888

    /*

    the code above runed in devtools console forwardFrame successfully,but failed in vba executejavascript.

    */

    if possible,share your source html.

    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;"

    var iframe = document.getElementById('mainiframe');

    var elmnt = iframe.contentWindow.document.getElementsByTagName("input")[3];

    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

    just equal

    elmnt?

    How did you make

    the code above runed in devtools console forwardFrame successfully?

    What is forwardFrame?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-06-24T07:57:27+00:00

    var iframe = document.getElementById('mainiframe');

    var elmnt = iframe.contentWindow.document.getElementsByTagName("input")[3];

    elmnt.value=888

    the code above runed in devtools console forwardFrame successfully,but failed in vba executejavascript.

    Was this answer helpful?

    0 comments No comments