📄 day5_5.html
字号:
<tr bgcolor="#FFFFFF">
<td colspan="2">-<a href="../../1-backend/database/php_mysql/index.html">PHP/MySQL</a></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2"><a href="../../1-backend/cgi_perl/perl_beginner/index.html">-Perl</a>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2">-<a href="../../1-teach/other/index.htm">其它</a> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#666699">
<div align="center"><font color="#FFFFFF">更多教程</font></div>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" height="17"><a href="../../1hdml/index.html">-HDML</a></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" height="23"><font face="宋体"><a href="../../1-backend/database/course/day1_1.html">-网络数据库</a></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" height="14"><a href="../../1-backend/protocols/ping/index.html"><font face="arial, helvetica, sans-serif">-ping</font></a></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" height="20"><a href="../../1-backend/cgi_perl/search_engine/index.html">-创建搜索引擎</a></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" height="16">-<a href="../../1adobe/GoLive/index.html">Adobe GoLive</a></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2"><a href="../../1-backend/cgi_perl/templates/index.html">-模板</a></td>
</tr>
<tr bgcolor="#666699">
<td colspan="2" align="center"><font color="#FFFFFF">合作伙伴</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="left">-<a href="http://www.5dmedia.com/" target="_blank">5D精英网</a></td>
</tr>
<tr align="center" bgcolor="#FFFFFF">
<td colspan="2"> <img src="../../Library/front_monkey.gif" width="59" height="68"></td>
</tr>
</tbody>
</table>
<!-- #EndLibraryItem --> </td>
<!-- End of headlines (column 1: left column) --> <!-- Gutter between columns 1 and 2 -->
<td width="10" height="794"><img src="http://www.sohu.com/images/pixel.gif" width=10></td>
<!-- Search box and directories (columns 2 and 3: middle columns, combined into one) -->
<td align=center valign=top width="558">
<div align="left"><!-- #BeginEditable "1" -->
<title>JavaScrip教程</title>
<strong>第五页:<font size="3">反馈表单处理器</font></strong>
<p align="JUSTIFY"><font size="3"></font><font size="4"> </font></p>
<ul>
<li><font size="3">
<table width="357" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>表单也是对象;他们有自己的方法、属性、及事件<br>
处理器。其中有一项就是<tt><font face="宋体">onSubmit</font>。</tt>
<p><font face="宋体"><tt>onSubmit</tt></font>的调用有以下两种情形:如果用户点击递<br>
交(<font face="宋体">Submit</font>)按钮,或用户在文字域内按了回车<br>
键 。试着点击下面的<font face="宋体">Submit</font>按钮看会发生什么情<br>
况。</p>
<form>
<p>
<input type="submit" value="Submit" name="submit">
</p>
</form>
<p>在<font face="宋体">Netscape</font>中,点击一个没有结果事件处理的<br>
<font face="宋体">Submit</font>按钮通常会导致刷新原有的页面。为了避免<br>
这种情况,你可以这样做:
</td>
</tr>
</table>
<ul>
<pre>
<font face="宋体"><form onSubmit="return false;">
<input type="submit" value="Submit">
</form>
</font></pre>
</ul>
<table width="357" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>试着点击下面的按钮<font face="宋体">: </font>
<form onSubmit="return false;">
<p><font face="宋体">
<input type="submit" value="Click on me" name="submit2">
</font></p>
</form>
<p><font face="宋体">Javascript</font>用<font face="宋体"><tt>return
false</tt></font>阻止浏览器刷新页面。<br>
另一个例子是阻止一个<font face="宋体"><tt>href</tt></font>转向赋值的<font face="宋体">URL
</font>。例<br>
如:链接
</td>
</tr>
</table>
<ul>
<pre>
<font face="宋体"><a href=<a href="http://www.mattmarg.com/">"http://www.mattmarg.com/"</a>
onClick="return false;">mattmarg!</a>
</font></pre>
</ul>
<table width="357" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>不会转向任何<font face="宋体">URL</font>,因为你给<font face="宋体">onClick</font>赋值为<font face="宋体">return
<br>
false</font>。
<p>以下是一个从用户获取信息的表单。在文字域中输入一些<br>
内容然后点击<font face="宋体">Return:</font></p>
<form name="text_entry_form" onSubmit="monkeyLove(); return false;">
<p><b><font face="宋体">Who does the monkey love: </font></b><font face="宋体">
<input type="text" name="monkey_love" size="40">
</font></p>
</form>
<p>以下是表单的编码:
</td>
</tr>
</table>
<ul>
<pre><font face="宋体"><form name="text_entry_form"
onSubmit="monkeyLove(); return false;">
<b>Who does the monkey love: </b>
<input type="text" name="monkey_love" size="40">
</form>
</font></pre>
</ul>
<table width="357" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>当你点击文字域中的<font face="宋体">Return</font>时,<font face="宋体"><tt>onSubmit</tt></font>处理器被<br>
调用执行函数<font face="宋体"><tt>monkeyLove()</tt></font>,该函数将改变文字域<br>
内的值。
<p>如果<font face="宋体">onsubmit</font>处理器中没有<font face="宋体"><tt>return
false</tt></font>语句的<br>
话,执行函数<font face="宋体"><tt>monkeyLove()</tt></font>会改变文字域内容,但<br>
由于同时网页内容会被刷新,从而又会将文字域的<br>
内容返回到原有的内容。为了阻止这种现象,就必<br>
须在<font face="宋体"><tt>onSubmit</tt></font>中加入<font face="宋体">return
false. </font></p>
<p>以下是<font face="宋体"><tt>monkeyLove()</tt> </font>函数的内容:
</td>
</tr>
</table>
<ul>
<pre><font face="宋体">function monkeyLove()
{
var who_it_is =
window.document.text_entry_form.monkey_love.value;
who_it_is =
'The monkey loves ' + who_it_is;
window.document.text_entry_form.monkey_love.value =
who_it_is;
}
</font></pre>
</ul>
</font>
<table width="357" border="0" cellspacing="0" cellpadding="0">
<font size="3">
<tr>
<td>下面这个例子中没有加入<font face="宋体">return false</font>,你将看到会发生<br>
什么情况:
<form name="text_entry_form2" onSubmit="monkeyLove2();">
<p><b><font face="宋体">Who does the monkey love: </font></b><font face="宋体">
<input type="text" name="monkey_love2" size="40">
</font></p>
</form>
</td>
</tr>
</font>
</table>
</li>
</ul>
<p><font face="宋体"><br>
<a href="day5_6.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_5.html">第五课课程介绍</a><br>
<font color="#FF0000">第二页</font> <a href="day5_2.html">介绍反馈表单</a><br>
<font color="#FF0000">第三页</font> <a href="day5_3.html">控制文字域的值</a><br>
<font color="#FF0000">第四页</font> <a href="day5_4.html">文字域事件</a><br>
<font color="#FF0000">第五页</font> 反馈表单处理器<br>
<font color="#FF0000">第六页</font> <a href="day5_6.html">文字域的练习</a><br>
<font color="#FF0000">第七页</font> <a href="day5_7.html">复选框</a><br>
<font color="#FF0000">第八页</font> <a href="day5_8.html">单选框</a><br>
<font color="#FF0000">第九页</font> <a href="day5_9.html">选单</a><br>
<font color="#FF0000">第十页</font> <a href="day5_10.html">在选单中应用<font face="宋体">onchange</font>命令</a></font></p>
<p align="left"><font face="宋体" size="3">[<a href="index.html">第1课</a>][<a href="day2_1.html">第2课</a>][<a href="day3_1.html">第3课</a>][<a href="day4_1.html">第4课</a>][第5课]</font></p>
<!-- #EndEditable --></div>
</td>
<!-- End of search box and directories (columns 2 and 3: middle columns, combined into one) -->
<!-- Gutter between columns 3 and 4 --> <!-- Other stuff (column 4: right column) -->
<!-- End of other stuff (column 4: right column) --> </tr>
</table>
<!-- End of table surrounding page contents -->
<hr noshade size=1 width=700>
<span class=eng><br>
Copyright (C) 1998-2000 Internet Technologies China. All rights reserved.
</span>
</center>
</body>
<!-- #EndTemplate --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -