📄 day5_3.html
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312-80">
<style type="text/css">
<!--
a:link { color: blue; text-decoration: none}
a:visited { color: purple; text-decoration: none}
a:hover { color: #CC0033; text-decoration: underline}
-->
</style>
<script language="JavaScript">
<!-- hide me
var first_part = "Now I'm the king of the swingers\nOh, the jungle VIP\nI've reached the top and had to stop\nAnd that's what botherin' me";
var second_part = "I wanna be a Webmonkey, mancub\nAnd stroll right into town\nAnd be just like the other Webmonkeys\nI wanna start monkeyin' around!";
// show me -->
</script>
<title>JavaScript教程</title>
</head>
<body topmargin="1" leftmargin="2">
<table border="0" width="591" cellspacing="0">
<tr>
<td bgcolor="#ffff99" width="451">JavaScript教程 - 第五课</td>
</tr>
<tr>
<td bgcolor="#FF6600" width="451"><a href="mailto:thau@wired.com">Thau</a></td>
</tr>
</table>
<div align="left">
<table border="0" width="630" cellspacing="0">
<tr>
<td width="458" valign="top" align="left"><small><small><br>
</small></small><strong>第三页:<font SIZE="3">控制文字域的值</font></strong> <p><font
size="3" face="宋体">将鼠标滑过该链接看看会发式什么事情。</font></p>
<table>
<tr>
<td colspan="2"><form name="first_form">
<p><font size="3" face="宋体"><input type="text" name="first_text"
value="Are you happy?" size="20"> </font></p>
</form>
</td>
<td></td>
</tr>
<tr>
<td><font size="3" face="宋体"><a href="#"
onMouseOver="window.document.first_form.first_text.value='Clap clap!';">Yes, and I know
it.</a> </font></td>
<td><font size="3" face="宋体"><a href="#"
onMouseOver="window.document.first_form.first_text.value='Sour puss!';">No!</a> </font></td>
</tr>
</table>
<p><font face="宋体">通过改变文字域的值就可实现这种奇妙的变换。</font>
<ul>
<pre><font face="宋体">
<form name="first_form">
<input type="text" name="first_text"
value="Are you happy?">
</form>
</font></pre>
</ul>
<p><font size="3" face="宋体">改变文字域的链接为:</font> <ul>
<pre><font face="宋体">
<a href="#"
onMouseOver="window.document.first_form.first_text.value='Clap clap!';">
Yes, and I know it.</a>
<a href="#"
onMouseOver="window.document.first_form.first_text.value='Sour puss!';">
No!</a>
</font></pre>
</ul>
<p><font face="宋体">意思是说,表单调用第1个表单,并将其值设为 'Clap
clap!'第<br>
2行作用相似。这同改变图象的src非常相似。只不过文字域改变<br>
的是值。 </font></p>
<p><font face="宋体">对textareas也可以采用类似的方法改变值:</font></p>
<table>
<tr>
<td colspan="2"><form name="form_two">
<p><font face="宋体"><textarea name="the_textarea" rows="10" cols="40">
Mouse over below to see the first verse of
The Webmonkey song, adapted from
"I Wanna Be Like You" (The Monkey Song)
from Walt Disney's The Jungle Book
written by Richard M. Sherman and Robert B. Sherman
</textarea> </font></p>
</form>
</td>
<td></td>
</tr>
<tr>
<td><font face="宋体"><a href="#"
onMouseOver="window.document.form_two.the_textarea.value=first_part;">Part 1</a> </font></td>
<td><font face="宋体"><a href="#"
onMouseOver="window.document.form_two.the_textarea.value=second_part;">Part 2</a> </font></td>
</tr>
</table>
<p><font face="宋体">表单编码:</font> <ul>
<pre><font face="宋体"><form name="form_two">
<textarea name="the_textarea" rows=10 cols=60>
Mouse over below to see the first verse of
The Webmonkey song, adapted from
"I Wanna Be Like You" (The Monkey Song)
from Walt Disney's <cite>The Jungle Book</cite>
written by Richard M. Sherman and Robert B. Sherman
</textarea>
</form>
</font></pre>
</ul>
<p><font face="宋体">注意该表单有一个名字:<tt>form_two</tt>,,并且文字区也有一个名字:<br>
<tt>the_textarea</tt>。 </font></p>
<p><font face="宋体">其链接和文字域的设定方法基本相同: </font><ul>
<pre><font face="宋体"><a href="#"
onMouseOver="window.document.form_two.the_textarea.value=first_part;">
Part 1</a>
<a href="#"
onMouseOver="window.document.form_two.the_textarea.value=second_part;">
Part 2</a>
</font></pre>
</ul>
<p><font face="宋体">唯一的不同之处在于将一个变量赋值给textareas,而不<br>
是将字符串赋值给它。该变量在HTML首部已经做了定义。<br>
以下是变量的字符串赋值:</font> <ul>
<pre><font face="宋体">
var first_part = "Now I'm the king of the swingers\nOh,
the jungle VIP\nI've reached the top and had to stop\nAnd
that's what botherin' me";
</font></pre>
</ul>
<p> </p>
<p><font face="宋体">注意<tt>"\n"</tt>是换行符。如果你在一个<tt><pre></tt>
并且或在一个<br>
textarea中写字,<tt>"\n"</tt> 换行符非常方便。</font></p>
<p><font face="宋体">除了改变表单元素的值,JavaScript还可以让你检测在表<br>
单中进行的事件。</font> <ul>
<pre><font face="宋体"><a href="#"
onMouseOver="window.document.form_two.the_textarea.value=first_part;">
Part 1</a>
<a href="#"
onMouseOver="window.document.form_two.the_textarea.value=second_part;">
Part 2</a>
</font></pre>
</ul>
<p><font face="宋体">唯一的不同之处在于将一个变量赋值给textareas,<br>
而不是将字符串赋值给它。该变量在HTML首部已经做<br>
了定义。以下是变量的字符串赋值:</font> <ul>
<pre><font face="宋体">var first_part = "Now I'm the king of the swingers\nOh,
the jungle VIP\nI've reached the top and had to stop\nAnd
that's what botherin' me";
</font></pre>
</ul>
<p> </p>
<p><font face="宋体">注意<tt>"\n"</tt>是换行符。如果你在一个<tt><pre></tt>
并且或在一个<br>
textarea中写字,<tt>"\n"</tt> 换行符非常方便。</font></p>
<p><font face="宋体">除了改变表单元素的值,JavaScript还可以让你检测在<br>
表单中进行的事件。<a href="day5_4.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_4.html">>></a></font></p>
<p align="left"><font face="宋体" size="3" color="#000000"><strong>JavaScript教程</strong></font><font
color="#FF0000" face="宋体" size="3"><br>
</font><font size="3"><font color="#FF0000">第一页</font> <a href="day5_3.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_3.html">第五课课程介绍</a><br>
<font color="#FF0000">第二页</font> <a href="day5_2.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_2.html">介绍反馈表单</a><br>
<font color="#FF0000">第三页</font> 控制文字域的值<br>
<font color="#FF0000">第四页</font> <a href="day5_4.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_4.html">文字域事件</a><br>
<font color="#FF0000">第五页</font> <a href="day5_5.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_5.html">反馈表单处理器</a><br>
<font color="#FF0000">第六页</font> <a href="day5_6.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_6.html">文字域的练习</a><br>
<font color="#FF0000">第七页</font> <a href="day5_7.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_7.html">复选框</a><br>
<font color="#FF0000">第八页</font> <a href="day5_8.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_8.html">单选框</a><br>
<font color="#FF0000">第九页</font> <a href="day5_9.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_9.html">选单</a><br>
<font color="#FF0000">第十页</font> <a href="day5_10.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_10.html">在选单中应用<font
face="宋体">onchange</font>命令</a></font></p>
<p align="left"><font face="宋体" size="3">[<a href="index.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/index.html">第1课</a>][<a
href="day2_1.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day2_1.html">第2课</a>][<a href="day3_1.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day3_1.html">第3课</a>][<a href="day4_1.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_1.html">第4课</a>][第5课]</font></p>
<hr align="left">
<p><font size="2">本文由<a href="javascript:if(confirm('http://chd.126.com/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://chd.126.com/'" tppabs="http://chd.126.com/" target="_blank">《</font><font
face="verdana, arial, geneva, sans-serif" size="2">CHD</font><font size="2">的网络教室》</a>根据<a
href="javascript:if(confirm('http://www.webmonkey.com.cn/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.webmonkey.com.cn/'" tppabs="http://www.webmonkey.com.cn/" target="_blank">《网猴》</a>相关文章改编,版权归<a
href="javascript:if(confirm('http://www.webmonkey.com.cn/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.webmonkey.com.cn/'" tppabs="http://www.webmonkey.com.cn/" target="_blank">《网猴》</a>所有</font></td>
</tr>
</table>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -