Using JavaScript script, I find the Internet a lot of, tried it on in the Google browser, all not line, you know how to do?
Write a test first:
HTML:
<script SRC="https://bbs.csdn.net/topics/tab_t.js" & gt; </script>
Tab_t. Js
Window. The onl oad=function () { Document. The onm ousedown=test1; } The function test1 () { Var elmItem=document. GetElementById (" usrname "); ElmItem. AddEventListener (" keydown ", function (e) {the console. The log (e.k ey, e.c. with our fabrication: har, e.k eyCode)}); //keyboard mode, how to use simulation to elmItem input string "aaa"?? }; Please prawns glad,
CodePudding user response:
The function test1 () { Var elmItem=document. GetElementById (" usrname "); ElmItem. Value +="a"; }; CodePudding user response:
reference 1/f, the sky wave response: The function test1 () { Var elmItem=document. GetElementById (" usrname "); ElmItem. Value +="a"; }; is the way to use analog keyboard input, can't use direct assignment, :) CodePudding user response:
refer to the second floor and nothing phase response: Quote: reference 1/f, the sky wave response: The function test1 () { Var elmItem=document. GetElementById (" usrname "); ElmItem. Value +="a"; }; is the way to use analog keyboard input, can't use direct assignment, :) By simulation, can only simulate the keydown event has occurred to trigger of the elements, can't let the text box input text, To make a text box input text need to use other methods CodePudding user response:
reference 3 floor sky waves reply: with simulation, can only simulate the keydown event has occurred to trigger of the elements, can't let the text box input text, To make text box input text need to use other method Thank you very much! The real question is this: Page has a text box, and a submit button, Given text box assignment, use script: htm_txt_Item. Value="https://bbs.csdn.net/topics/mystring" assignment, submit prompt, content of the text box is empty (in fact, the box is a value), If manual input, click submit, tip was successful, Therefore, I think of, with analog keyboard input to solve this problem, are trying to, Everybody encountered this problem? How to solve?