Simulate a click on submit in javascript

I want to be able to submit the form after the page is loaded through Javascript.

I am writing a Google Chrome extension.

While the extension can fill in the text in the input field, but I can’t figure out how to proceed to the next step, which the user clicks “Submit”. Please help. Thank.

EDIT: Excuse my editing. It is unclear that he wrote a chrome extension for those of us who are chatting. --drachenstern

+3
source share
2 answers

Have you tried something like document.getElementById('myForm').submit()?

With a form similar (after EDIT):

<form id="myform" action="/url/To/Action">
  ...
</form>
...
<script>
  document.getElementById('myForm').submit();
</script>

EDIT :
script form. body, , DOM .

+4

document.getElementById('form1'). submit();

+1

Source: https://habr.com/ru/post/1774178/


All Articles