javascriptѧϰÐĵÃ(3)
1¡¢JavaScriptÐÅÏ¢µÄÊäÈë
¡¡¡¡Í¨¹ýʹÓÃJavaScriptÖÐËùÌṩµÄ´°¿Ú¶ÔÏó·½·¨prompt(), ¾ÍÄÜÍê³ÉÐÅÏ¢µÄÊäÈë¡£¸Ã·½·¨ÌṩÁË×î¼ò±ãµÄÐÅÏ¢ÊäÈ뷽ʽ£¬Æä»ù±¾¸ñʽÈçÏ£º
Window.prompt("ÌáʾÐÅ", Ô¤¶¨ÊäÈëÐÅÏ¢);
¡¡¡¡´Ë·½·¨Ê×ÏÈÔÚä¯ÀÀÆ÷´°¿ÚÖе¯³öÒ»¸ö¶Ô»°¿ò, ÈÃÓû§×ÔÐÐÊäÈëÐÅÏ¢¡£Ò»µ©ÊäÈëÍê³Éºó£¬¾Í·µ»ØÓû§ËùÊäÈëÐÅÏ¢µÄÖµ¡£Àý:
test=prompt£¨“ÇëÊäÈëÊý¾Ý:”£¬”this is a JavaScript”£©
¡¡¡¡Êµ¼ÊÉÏprompt()ÊÇ´°¿Ú¶ÔÏóµÄÒ»¸ö·½·¨¡£ÒòΪȱʡÇé¿öÏÂËùÓõĶÔÏó¾ÍÊÇwindow¶ÔÏó, ËùÒÔwindows¶ÔÏó¿ÉÒÔÊ¡ÂÔ²»Ð´¡£
¡¡
2¡¢Êä³öÏÔʾ
¡¡¡¡Ã¿ÖÖÓïÑÔ£¬¶¼±ØÐëÌṩÐÅÏ¢Êý¾ÝµÄÊä³öÏÔʾ¡£JavaScriptÒ²ÊÇÒ»Ñù£¬ËüÌṩÓм¸¸öÓÃÓÚÐÅÏ¢Êä³öÏÔʾµÄ·½·¨¡£±È½Ï³£ÓõÄÓÐwindow.alert()¡¢document.writeºÍ¼°document.writln()·½·¨¡£
£±)¡¢document.write()·½·¨ºÍdocument.writeln()·½·¨
¡¡¡¡documentÊÇJavaScriptÖеÄÒ»¸ö¶ÔÏóÔÚËüÖзâ×°Ðí¶àÓÐÓõķ½·¨£¬ÆäÖÐwrite()ºÍwriteln()¾ÍÊÇÓÃÓÚ½«Îı¾ÐÅÏ¢Ö±½ÓÊä³öµ½ä¯ÀÀÆ÷´°¿ÚÖеķ½·¨¡£
document.write()£»
document.writeln()£»
˵Ã÷£º
¡¡write()ºÍwriteln()·½·¨¶¼ÊÇÓÃÓÚÏòä¯ÀÀÆ÷´°¿ÚÊä³öÎı¾×Ö´®£»
¡¡¶þÕßµÄΨһÇø±ð¾ÍÊÇwriteln()·½·¨×Ô¶¯ÔÚÎı¾Ö®ºó¼ÓÈë»Ø³µ·û¡£
£±¡¢Ê²Ã´ÊÇ´°Ìå¶ÔÏó
´°Ì壨Form£©:Ëü¹¹³ÉÁËWebÒ³ÃæµÄ»ù±¾ÔªËØ¡£Í¨³£Ò»¸öWebÒ³ÃæÓÐÒ»¸ö´°Ìå»ò¼¸¸ö´°Ì壬ʹÓÃForms[]Êý×éÀ´ÊµÏÖ²»Í¬´°ÌåµÄ·ÃÎÊ¡£
<form Name=Form1>
<INPUT type=text...>
<Input type=text...>
<Inpup byne=text...>
</form>
<form Name=Form2>
<INPUT type=text...>
<Input type=text...>
</form>
¡¡¡¡ÔÚForms[0]Öй²ÓÐÈý¸ö»ù±¾ÔªËØ£¬¶øForms[1]ÖÐÖ»ÓÐÁ½¸öÔªËØ¡£
¡¡¡¡´°Ìå¶ÔÏó×îÖ÷ÒªµÄ¹¦ÄܾÍÊÇÄܹ»Ö±½Ó·ÃÎÊHTMLÎĵµÖеĴ°Ì壬Ëü·â×°ÁËÏà¹ØµÄHTML´úÂ룺
<Form
Name ="±íµÄÃû³Æ"
Target ="Ö¸¶¨ÐÅÏ¢µÄÌá½»´°¿Ú"
action ="½ÓÊÕ´°Ìå³ÌÐò¶ÔÓ¦µÄURL"
Method =ÐÅÏ¢Êý¾Ý´«ËÍ·½Ê½(get/post)
enctype ="´°Ìå±àÂ뷽ʽ"
[onsubmit ="JavaScript´úÂë"]>
</Form>
¡¡
£²¡¢´°Ìå¶ÔÏóµÄ·½·¨
¡¡¡¡´°Ìå¶ÔÏóµÄ·½·¨Ö»ÓÐÒ»¸ö--submit()·½·¨£¬¸Ã·½·¨Ö÷Òª¹¦ÓþÍÊÇʵÏÖ´°ÌåÐÅÏ¢µÄÌá½»¡£ÈçÌá½»Mytest´°Ìå,ÔòʹÓÃÏÂÁиñʽ£º
document.mytest.submit()
¡¡
£³¡¢´°Ìå¶ÔÏóµÄÊôÐÔ
¡¡¡¡´°Ìå¶ÔÏóÖеÄÊôÐÔÖ÷Òª°üÀ¨ÒÔÏ£ºelements name action target encoding m
Ïà¹ØÎĵµ£º
±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔÀ´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷ÔÒò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......
Ò³ÃæÌá½»Êý¾ÝÒ»°ãÓÐÁ½ÖÖ·½·¨£ºget,post¡£post¾ÍÊÇËùνµÄformÌá½»£¬Ê¹ÓÃÊÓͼ£»getÊÇͨ¹ýurlÌá½»¡£
Get·½·¨Ò»°ãÓúǫ́´úÂ루Èçasp,asp.net£©»ñµÃ²ÎÊý£¬´úÂëºÜ¼òµ¥£ºRequest.QueryString["id"];¼´¿É»ñÈ¡¡£
ÓÐЩʱºòÐèÒªÖ±½ÓÔÚǰ̨»ñÈ¡url²ÎÊý£¬ÒªÓõ½javascript£¬jsûÓÐÖ±½Ó»ñÈ¡url²ÎÊýµÄ·½·¨£¬ÄÇô£¬ÎÒÃÇÈçºÎͨ¹ýjs ......
ʹÓùýajaxµÄ¶¼³£¼ûÕâÑùµÄ´úÂ룺
<a href="javascript:doTest2();void(0);" mce_href="javascript:doTest2();void(0);">here</a>
µ«Õâ¶ùµÄvoid(0)¾¿¾¹ÊǺκ¬ÒåÄØ£¿
JavascriptÖÐvoidÊÇÒ»¸ö²Ù×÷·û£¬¸Ã²Ù×÷·ûÖ¸¶¨Òª¼ÆËãÒ»¸ö±í´ïʽµ«ÊDz»·µ»ØÖµ¡£
void ²Ù×÷·ûÓ÷¨¸ñʽÈçÏ£º
1. jav ......
³ýÁËÓÃgetElementByTagName µÄÁíÒ»ÖÖ»ñÈ¡¶ÔÏ󼯺ϵķ½·¨
<!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" conte ......