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-07-04T23:33:21+00:00

    there is new question

    web page show value which input by execute js code,but unable save it.

    old value is 1 , input new value, but move focus to other element, the value back to 0.

    it look like missing execute some actoin.

    That is true.

    The ui is rendered by react JSX

    https://react.dev/

    ,so it is not same as native javascript to handle dom element directly.

    You need to hack some thing to input data.

    Alternatively,

    One automate way is 按键精灵

    https://club.excelhome.net/thread-568512-1-1.html?\_dsign=66301406

    Or grasp the Http communiaction with Fiddler.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-07-04T09:53:24+00:00

    there is new question

    web page show value which input by execute js code,but unable save it.

    old value is 1 , input new value, but move focus to other element, the value back to 0.

    it look like missing execute some actoin.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-07-03T03:46:20+00:00

    thanks,peiyezhu!

    succeed in inputing value to web page with iframe.

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

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

    var elmntReason = elmnt2.contentWindow.document.getElementsByTagName("input")[17];

    var elmntValue=elmnt2.contentWindow.document.getElementsByTagName("input")[20];

    elmntReason.value='test';

    elmntValue.value=899

    use getElementsByTagName,still failed in using querySelector,but it is not important.

    wish this post can help many people

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-06-27T09:56:05+00:00

    Was this answer helpful?

    0 comments No comments