ѧϰJavaScript£¨Ò»£©
Õ⼸ÌìÔÚѧJavaScriptµÄ»ù´¡ÖªÊ¶£¬¾Í°Ñ»ù´¡µÄ֪ʶÕûÀíһϡ£
1¡¢JavaScriptµÄËÄÖÖ»ù±¾µÄÊý¾ÝÀàÐÍ£ºÊýÖµ£¨ÕûÊýºÍʵÊý£©¡¢×Ö·û´®ÐÍ£¨ÓÓ”»òÕß‘’À¨ÆðÀ´µÄ×Ö·û»òÕßÊýÖµ£©¡¢²¼¶ûÐÍ£¨true»òfalse£©¡¢¿ÕÖµ¡£
2¡¢JavaScriptµÄ±äÁ¿
ÉùÃ÷±äÁ¿£º±äÁ¿Ôڽű¾ÖеÚÒ»´Î³öÏÖʱºòÔÚÉùÃ÷ÖУ¨var£©£¬±äÁ¿µÄ½Å±¾µÚÒ»´ÎÓõ½Ê±¾ÍÉèÖÃÓÚÄÚ´æÖУ¬±ãÓÚÒÔºóʹÓ᣶ÔÓÚ±äÁ¿»¹ÓÐÒ»¸öÖØÒªÐÔ------ÄǾÍÊDZäÁ¿µÄ×÷ÓÃÓò¡£ÔÚJavaScriptͬÑùÓÐÈ«¾Ö±äÁ¿ºÍ¾Ö²¿±äÁ¿¡£È«¾Ö±äÁ¿Ö®ËùÒÔÔÚËùÓк¯ÊýÖ®Í⣬Æä×÷ÓÃÕû¸öº¯Êý£¬¶ø¾Ö²¿º¯ÊýÊǶ¨ÒåÔÚº¯ÊýÌåÖ®ÄÚ£¬Ö»¶Ô¸Ãº¯ÊýʹÓ㬶ø¶ÔÆäËûº¯ÊýÔòÊDz»¿É¼ûµÃ¡£
3¡¢±í´ïʽºÍÔËËã·û
±í´ïʽ·ÖËãÊõ±í´ïʽ¡¢×Ö´®±í´ïʽ¡¢¸³Öµ±í´ïʽ¡¢²¼¶û±í´ïʽ
ÔËËã·û·Öµ¥Ä¿ÔËËã·ûºÍË«Ä¿ÔËËã·û¡¢ÈýÄ¿ÔËËã·û
µ¥Ä¿ÔËËã·û£º-£¨È¡·´£©¡¢~£¨È¡²¹£©¡¢++£¨µÝ¼Ó1£©¡¢- -£¨µÝ¼õ1£©
Ë«Ä¿ÔËËã·û£º²Ù×÷Êý1 ÔËËã·û ²Ù×÷Êý2
ÈýÄ¿ÔËËã·û£º²Ù×÷Êý£¿½á¹û1£º½á¹û2
ʵÀý:¼òµ¥µÄÅÜÂíµÆЧ¹û£º
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script language="javascript">
var msg="»¶Ó´ó¼Ò½øÈ룬ÕâÊÇÒ»¸ö¼òµ¥µÄÅÜÂíµÆµÄЧ¹û£¡";
var speech = 100;
var seq=0;
function Scroll() {
document.pmdForm.pmdtext.value = msg.substring(seq, msg.length)+ msg.substring(0, msg.length);
seq++;
if ( seq > msg.length ) { seq = 0 };
window.setTimeout("Scroll();", speech );
}
</script>
<title>ÎÞ±êÌâÎĵµ</title>
</head>
<body OnLoad="Scroll();" >
<form name="pmdForm">
<input name="pmdtext" type="text" />
</form>
</body>
</html>
Ч¹ûÈçÏÂͼ£º
4¡¢JavaScriptµÄ³ÌÐò¹¹³É
³ÌÐò¿ØÖÆÁ÷
IfÌõ¼þÓï¾ä¡¢forÑ»·Óï¾ä¡¢whileÑ»·¡¢breakºÍcontinueÓï¾ä
º¯Êý
4.1 JavaScriptº¯Êý¶¨Òå
Function º¯ÊýÃû£¨²ÎÊý£¬±äÔª£©{
º¯ÊýÌ壻
Return ±í´ïʽ£»
}
˵Ã÷£º
¡¡µ±µ÷Óú¯Êýʱ,ËùÓñäÁ¿»ò×ÖÃæÁ¿¾ù¿É×÷Ϊ±äÔª´«µÝ¡£
¡¡º¯ÊýÓɹؼü×ÖFunction¶¨Òå¡£
¡¡º¯ÊýÃû£º¶¨Òå×Ô¼
Ïà¹ØÎĵµ£º
JavaScriptÔÊÐí´´½¨ºÍ´ò¿ª´ú±íHTMLÎı¾, form¶ÔÏóºÍframeµÄ´°¿Ú. window¶ÔÏóÊÇJavaScript¿Í»§²ã´Î½á¹¹µÄ×²ã¶ÔÏó, formÔªËغÍÈ«²¿JavaScript´úÂ붼ÊÇ´æÔÚÓÚÎĵµÖÐ,¶øÎĵµ±»×°Ôؽø´°¿Ú. ΪÁËÀí½â´°¿ÚÔõÑù¹¤×÷,Äã¿ÉÒÔ¿ØÖƲÙ×÷ÕâЩ´°¿Ú.
´ò¿ªºÍ¹Ø±Õ´°¿Ú
µ±Óû§Æô¶¯(launch)Navigatorʱ,½«×Ô¶¯´´½¨Ò»¸ö´°¿Ú.Óû§»¹¿ÉÒÔÊ¹Ó ......
JavaScriptÔÊÐí´´½¨ºÍ´ò¿ª´ú±íHTMLÎı¾, form¶ÔÏóºÍframeµÄ´°¿Ú. window¶ÔÏóÊÇJavaScript¿Í»§²ã´Î½á¹¹µÄ×²ã¶ÔÏó, formÔªËغÍÈ«²¿JavaScript´úÂ붼ÊÇ´æÔÚÓÚÎĵµÖÐ,¶øÎĵµ±»×°Ôؽø´°¿Ú. ΪÁËÀí½â´°¿ÚÔõÑù¹¤×÷,Äã¿ÉÒÔ¿ØÖƲÙ×÷ÕâЩ´°¿Ú.
´ò¿ªºÍ¹Ø±Õ´°¿Ú
µ±Óû§Æô¶¯(launch)Navigatorʱ,½«×Ô¶¯´´½¨Ò»¸ö´°¿Ú.Óû§»¹¿ÉÒÔÊ¹Ó ......
var adDate=document.getElementById ("txts").value;
var pattern = /^[1-9]\d{3}-((0[1-9]{1})|(1[0-2]{1}))-((0[1-9]{1})|([1-2]{1}\d{1})|(3[0-1]{1}))$/;
& ......
2 ·â×°
ÏÂÃæÎÒÃǾÍÀ´ÌÖÂÛ¾ßÌåµÄ·â×°¡£Ê×ÏÈ˵һÏ´ó¼Ò×îÊìϤµÄ¼¸ÖÖ·â×°£ºË½ÓÐʵÀý³ÉÔ±¡¢¹«ÓÐʵÀý³ÉÔ±ºÍ¹«Óо²Ì¬³ÉÔ±¡£×îºó»áÌÖÂÛһϴó¼ÒËù²»ÊìϤµÄ˽Óо²Ì¬³ÉÔ±ºÍ¾²Ì¬ÀàµÄ·â×°°ì·¨¡£ÒòΪÏÂÃæÒªÌÖÂÛµÄÊÇÃæÏò¶ÔÏó±à³Ì£¬ËùÓе±º¯Êý×÷ΪÀàÀ´¶¨ÒåºÍʹÓÃʱ£¬ÎÒÃÇÔÝÇÒ½«Æä³ÉΪÀà¡£
2.1 ˽ÓÐʵÀý³ÉÔ±
˽ÓÐʵÀý³ÉÔ±ÔÚ JavaScript ......
ÀûÓÃÔÐͼ̳еĹؼüÓÐÁ½²½²Ù×÷£º
Ê×ÏÈ´´½¨Ò»¸ö¸¸ÀàµÄʵÀý»¯¶ÔÏó£¬È»ºó½«¸Ã¶ÔÏ󸳸ø×ÓÀàµÄ prototype ÊôÐÔ¡£
ÕâÑù£¬¸¸ÀàÖеÄËùÓй«ÓÐʵÀý³ÉÔ±¶¼»á±»×ÓÀà¼Ì³Ð¡£²¢ÇÒÓà instanceof ÔËËã·ûÅжÏʱ£¬×ÓÀàµÄʵÀý»¯¶ÔÏó¼ÈÊôÓÚ×ÓÀ࣬ҲÊôÓÚ¸¸Àà¡£
È»ºó½«×ÓÀà±¾Éí¸³Öµ¸øËüµÄ prototype µÄ constructor ÊôÐÔ¡££¨×¢Ò⣺ÕâÀ︳ֵµÄʱº ......