<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> test01 </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta content = "Microsoft Visual Studio. NET 7.1" name = "generator">
<Meta content = "JavaScript" name = "vs_defaultclientscript">
<Meta content = "http://schemas.microsoft.com/intellisense/ie5" name = "vs_targetschema">
<Script language = "JavaScript">
Function selectallcontent1 ()
{
Form1.aaa. Select ();
}
Function selectallcontent ()
{
Alert ("You clicked on me! @");
Document. All. AAA. Select ();
}
</SCRIPT>
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<Input id = "AAA" style = "Z-INDEX: 104; left: 184px; position: absolute; top: 120px" type = "text"
Value = "Get focus selected content" onfocus = "selectallcontent ()"> </form>
</Body>
</Html>
Bytes -------------------------------------------------------------------------------------------------------------------
First, declare that the post has not been re-posted. Please refer to it,
I have already pasted the above example, but some scriptsCodeIt needs to be reused. We certainly don't want to copy one copy every time and stick it elsewhere.
Let's solve the problem of script reusability !!!!
write the script code to a text file:
name the text file axzhz. JS (Note: The file suffix is changed to JS, and the file type has changed)
then use the following code to call axzhz. JS file
The preceding example changes:
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> test01 </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta content = "Microsoft Visual Studio. NET 7.1" name = "generator">
<Meta content = "JavaScript" name = "vs_defaultclientscript">
<Meta content = "http://schemas.microsoft.com/intellisense/ie5" name = "vs_targetschema">
<SCRIPT src = axzhz. js type = text/JavaScript> </SCRIPT>
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<Input id = "AAA" style = "Z-INDEX: 104; left: 184px; position: absolute; top: 120px" type = "text"
Value = "Get focus selected content" onfocus = "selectallcontent ()"> </form>
</Body>
</Html>
Of course, other files can also use the above method to call the script