This feature is often used in replies and references, that is, clicking a reply or reference, such as having the input focus appear in the message input box, and if the anchor is used to locate, the input focus cannot be activated.
Copy Code code as follows:
JAVASCRIPT:DOCUMENT.GETELEMENTBYID ("id"). focus ();
or Javascript:document.all.id.focus ();
or Javascript:document.all.name.focus ();
Example:
Copy Code code as follows:
<input type= "text" Name= "tt" id= "tt" >
<input type= "button" Name= "BT" id= "onclick=" Javascript:document.all.tt.focus (); "value=" to set focus on text box ">
Take a closer look at the responses and references used by this blog and how the focus is positioned to the right of the text.
Copy Code code as follows:
//reference Call function
Function quote (name,id) {
var quotemsg=document.getelemen Tbyid (ID). InnerHTML;
var Content=document.getelementbyid ("comment");
Quotemsg=quotemsg.replace (//g," ~^ "). Replace (/<br>/g, ' n ');
Content.focus ();//To get focus to the right of the text, this line of code is preceded by
content.value=quotemsg+ ' +name+ ' + ' n ' + ' —————————————————————— ' + ' n '; Fill in the text
return false;//Cancel the effect of href
}
//Reply to auto-enter name function
function backcomment (msg) {
Backdb=document. getElementById (' comment ');
Backdb.focus ();
backdb.value=msg+ ' n ';
return false;
//return true; original anchor to locate
}