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-20T04:11:06+00:00

    the code which you post above, i execute it in vba,correct.

    i do not think my selector is wrong.

    the reason is that i set value successfully in chrome devtool console with this selector.

    but i execute same jscode in vba using edgebrowser.executejavascript(jsode), no error report,just no value show in web page.

    the selector acquire by copying jspath in devtools.

    jscode=document.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').value=88

    thanks for you help!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-06-19T23:34:22+00:00

    I can not check your dom structure without the source html.

    test:

    url="https://e.anyoupin.cn/EData/index.php?p=Tools%2FDisTbl&find=cli_add_html%7E%0D%0A<input+type%3Dtext+class%3D%22testClass%22%2F>%0D%0A%3B"

    me.edgebrowser.Navigate (url)

    jscode="a=document.querySelector("".testClass"");a.value=88"

    me.edgebrowser.executejavascript(jscode)

    if the above test works,your edge installed succussfully but your dom selector may not correct.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-06-19T06:12:13+00:00

    sorry,connect by vpn

    is there any other method?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-06-19T05:51:40+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

    web page with frames?

    Can you share the url of the web page?

    Was this answer helpful?

    0 comments No comments