JavaScript初体验之小试身手(全代码)_AX
<!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("你点着我了!@");
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="获得焦点选中内容" onfocus="selectAllContent()"></form>
</body>
</HTML>
-----------------------------------------------------------------------------------------------------------------
拷贝以上代码到一空文本文件中,把文件名重命名为:AXzhz.htm (注意,把文件后缀也改了)
用IE打开试试,当光标移到文本框内后,首先打开一个窗口,然后文本框的内容被全部选中....
【重点】事件onfocus是控件获得焦点时触发:onfocus="selectAllContent()"
下面两句完全相同,aaa为文本框名,select()方法是选中所有内容,,,,,,方法有很多,自己去搜相关信息
document.all.aaa.select();
Form1.aaa.select();
<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("你点着我了!@");
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="获得焦点选中内容" onfocus="selectAllContent()"></form>
</body>
</HTML>
-----------------------------------------------------------------------------------------------------------------
拷贝以上代码到一空文本文件中,把文件名重命名为:AXzhz.htm (注意,把文件后缀也改了)
用IE打开试试,当光标移到文本框内后,首先打开一个窗口,然后文本框的内容被全部选中....
【重点】事件onfocus是控件获得焦点时触发:onfocus="selectAllContent()"
下面两句完全相同,aaa为文本框名,select()方法是选中所有内容,,,,,,方法有很多,自己去搜相关信息
document.all.aaa.select();
Form1.aaa.select();
少帮主的斧头好久不饮血了!