JAVASCRIPT ½Ì³Ì4 ¸¶Ê×ê¿
µÚËļ¯
--------------------------------------------------------------------------------
ÕâÕÂÎÒ½«¸æËßÄúÈçºÎÔÚ״̬ÁÐ (statusbar) (Ò²¾ÍÊÇÄúä¯ÀÀÆ÷×îÏ·½ÏÔʾ URLs µÄÄÇÒ»ÐÐ) ÏÔʾÎÄ×Ö£¬²¢ÇÒ½«½ÌÄú 'ÅÜÂíµÆ' (ÒÔϼò³Æ scroller ) µÄ¹¤×÷ÔÀí¡£ËäÈ»ÒÔ
JavaScript Íê³ÉµÄ scroller Ä¿Ç°ÈÔÓÐЩÎÊÌâ (ÉÔáá»áÌáµ½ÎÊÌâÔÚÄĶù?)£¬µ«ÎÒ»¹ÊǸæËßÄúËüÊÇÈçºÎд³ÉµÄ¡£
Ê×ÏÈ£¬ÈçºÎ½«ÎÄ×ÖÌîÈë statusbar ÄØ?ÏÂÊöÓï·¨½«¸æËßÄúÈçºÎ×öµ½ÕâÏÄÜ: (°´Ï°´Å¥ááÇë×¢ÊÓ statusbar µÄ±ä»¯)
ºÜÐÂÆæ°É! Çë¿´¿´ÔʼÂë :
<html>
<head>
<script language="JavaScript">
<!-- Hide
function statbar(txt) {
window.status = txt;
}
// -->
</script>
</head>
<body>
<form>
<input type="button" name="look" value="дÈëÎÄ×Ö" onclick="statbar('àË ! Õâ¾ÍÊÇ״̬
ÁÐ (statusbar) !');">
<input type="button" name="erase" value="Çå³ýÎÄ×Ö" onclick="statbar('');">
</form>
</body>
</html>
ÎÒÖÆ×÷ÁËÁ½¸ö¶¼»áºô½Ð statbar(txt) º¯Ê½ (function) µÄ°´Å¥¡£µ±´Ëº¯Ê½±»ºô½Ðáᣬ×Ö´®¾ÓÉÀ¨»¡ÖеıäÊý txt ´«¸ø statbar(txt)¡£ (²»Ò»¶¨ÒªÓà txt£¬ÓñðµÄ±äÊýÃûÒ²¿ÉÒÔ)
¡£µ±µçÄÔÖ´Ðе½ <form> tag ʱ£¬ Ò»µ©°´Ï°´Å¥¾Í»áºô½Ð statbar(txt)¡£µ«ÊǵçÄÔ²¢Ã»ÓÐÂíÉϽ« txt µÄÄÚÈÝдÔÚ statusbar£¬Ö»Êǽ«ÓûÏÔʾµÄ×Ö´®´æÈë txt¡£»»¾ä»°Ëµ£¬½åÓɺô
½Ðº¯Ê½£¬Ö»ÊÇÈñäÊý txt µÃµ½Ò»¸öÖµ¡£Òò´Ëµ±Äú°´Ï 'дÈëÎÄ×Ö' Õâ¸ö°´Å¥áᣬ»áºô½Ð statbar(txt) ¶øÇÒ 'àË ! Õâ¾ÍÊÇ״̬ÁÐ (statusbar) !' Õâ¸ö×Ö´®»á´æÈë txt ÖС£ßÝ !
½²ÁËÕâ÷á¶àÖ»ÊÇÏë¸æËßÄúÕâÖÖд·¨¿ÉÔ¤ÁôһЩµ¯ÐÔ¡£Ê²÷ᵯÐÔÄØ?¾ÍÊÇÄú¿ÉÖظ´Ê¹Óà txt Õâ¸ö±äÊý¡£Äú¿´¿´µÚ¶þ¸ö°´Å¥£¬ËüÒ²ÊǺô½ÐÏàͬµÄº¯Ê½¡£ÈôÄú²»ÀûÓÃÒ»¸ö±äÊýÀ´´«µÝ×Ö´®
µÄ»°£¬¾Í±ØÐëдÁ½¸ö²»Í¬µÄº¯Ê½ÁË¡£
ÄÇ÷á statbar(txt) µ½µ××öÁËЩʲ÷á?Æäʵûʲ÷ᣬֻÊǽ« txt µÄÄÚÈÝдÈë±äÊý window.statusÖС£ÕâÊÇÓÉ window.status = txt; ×öµÄ¡£ÁíÍâÈôÏëÏû³ýÎÄ×Ö£¬Ö»ÐèËÍÒ»¸ö¿Õ×Ö´®
('') ¸ø statusbar¡£Çë×¢Ò⣬ÒòΪÔÚ onClick ÖÐÎÒÃÇÒѾʹÓÃË«ÒýºÅ " £¬ËùÒÔÕâÀï±ØÐëÓõ¥ÒýºÅ ' ¡£ÕâÊÇΪÁËÈÃä¯ÀÀÆ÷±æÈÏÄÄÁ½¸öÒýºÅÊÇÒ»¶ÔµÄ£¬Òò´ËÄú±ØÐèË«ÒýºÅºÍµ¥ÒýºÅ
½»ÌæʹÓá£
Óɴ˷ݼò½éÎļþµÚ¶þÕÂÄúÒÑѧ¹ý onMouseOver µÄÌØÐÔÁË :
<
Ïà¹ØÎĵµ£º
ÓÉÓÚTEXTAREAûÓÐmaxlength,²»ÄÜÕâÑùÏÞÖÆtextarea³¤¶È£¬ µ«Í¨¹ýJAVASCRIPT ¾ÍÄÜʵÏÖµ½
<mce:script type="text/javascript"><!--
function limitLength(obj, length) {
var desc = obj.value;
obj.value = substr(obj.value,length);
}
function substr(str,length){
......
Ò»£¬È«¾Ö±äÁ¿ºÍ¾Ö²¿±äÁ¿µÄ±È½Ï
<script type="text/javascript">
<!--
var msg = 'È«¾Ö±äÁ¿';
function show()
{
msg = '¾Ö²¿±äÁ¿'; //ÐÞ¸ÄÈ«¾Ö±äÁ¿µÄÖµ
}
show();
alert(msg); //´ËʱµÄֵΪ‘¾Ö²¿±äÁ¿’
//-->
</script> <script type="text/javascript" ......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<mce:style type="text/css"><!--
table,tr,td {
background-position: center;
border-width: 1px;
border-style: solid;
border-coll ......
confirm(string) ·½·¨
1¡¢ÓÐÒ»¸östringÀàÐͲÎÊý£¬ËüµÄÖµ¾ÍÊÇÔÚ¶Ô»°¿òÖеÄÎı¾ÐÅÏ¢¡£
2¡¢boolean ÀàÐ͵ķµ»ØÖµ¡£Ñ¡Ôñ“È·¶¨”·µ»ØµÄ¾ÍÊÇtrue,Ñ¡Ôñ“È¡Ïû”·µ»Øfalse¡£
¾ÙÀý£º
<script type="text/javascript">
function cfm() {
i ......
¾«Í¨ JSÕýÔò±í´ïʽ
ÕýÔò±í´ïʽ¿ÉÒÔ:
•²âÊÔ×Ö·û´®µÄij¸öģʽ¡£ÀýÈ磬¿ÉÒÔ¶ÔÒ»¸öÊäÈë×Ö·û´®½øÐвâÊÔ£¬¿´ÔÚ¸Ã×Ö·û´®ÊÇ·ñ´æÔÚÒ»¸öµç»°ºÅÂëģʽ»òÒ»¸öÐÅÓÿ¨ºÅÂëģʽ¡£Õâ³ÆΪÊý¾ÝÓÐЧÐÔÑéÖ¤
•Ìæ»»Îı¾¡£¿ÉÒÔÔÚÎĵµÖÐʹÓÃÒ»¸öÕýÔò±í´ïʽÀ´±êʶÌض¨ÎÄ×Ö£¬È»ºó¿ÉÒÔÈ«²¿½«Æäɾ³ý£¬»òÕßÌ滻Ϊ±ðµÄÎÄ×Ö
•¸ù¾ÝÄ£Ê ......