JavaScriptʹÓ÷½·¨ºÍ¼¼ÇÉ´óÈ«
JavaScriptʹÓ÷½·¨ºÍ¼¼ÇÉ´óÈ«
ÓÐЩʱºòÄ㾫ͨһÃÅÓïÑÔ£¬µ«ÊǻᷢÏÖÄãÆäʵÕûÌìÔÚºÍÆäËüÓïÑÔ´ò½»µÀ£¬Ò²ÐíÄãÒÔΪÕâЩ΢²»×ãµÀ£¬²»ÖÁÓÚÓ°ÏìÄãµÄ¿ª·¢½ø¶È£¬µ«Ç¡Ç¡ÊÇÕâЩÄã²»ÖØÊӵĶ«Î÷»áÀË·ÑÄãºÜ¶àʱ¼ä£¬ÎÒÒ»Ö±ÒÔΪÎÒÔçÔÚ¼¸Äêǰ¾ÍÒѾ¾«Í¨JavaScriptÁË£¬Ö±µ½Ä¿Ç°£¬ÎÒ²ÅÔ½À´Ô½¾õµÃJavaScriptÔ¶±ÈÎÒÏëÏóµÄ¸´ÔÓºÍÇ¿´ó£¬ÎÒ¿ªÊ¼³ç°ÝËü£¬¾ÍÏñ³ç°ÝËùÓÐOOPÓïÑÔÒ»Ñù¡«
³Ã׎ÚÈյĿÕ϶£¬°ÑÓйØJavaScriptµÄ·½·¨ºÍ¼¼ÇÉÕûÀíÏ£¬ÈÃÿ¸öÔÚΪJavaScript¶ø·³ÄÕµÄÈËÃ÷°×£¬JavaScript¾ÍÕâô»ØÊ£¡²¢Ï£ÍûJavaScript»¹¿ÉÒÔ³ÉΪÄãµÄÅóÓÑ£¬ÈÃÄã»íÈ»¿ªÀÊ£¬ÔÚÏîÄ¿ÖиüºÃµÄÓ¦Óá«
ÊʺÏÔĶÁ·¶Î§£º¶ÔJavaScriptÒ»ÎÞËùÖª¡«À뾫ֻͨ²îÒ»²½Ö®Ò£µÄÈË
»ù´¡ÖªÊ¶£ºHTML
JavaScript¾ÍÕâô»ØÊ£º»ù´¡ÖªÊ¶
1 ´´½¨½Å±¾¿é
1: <script language="JavaScript">
2: JavaScript code goes here
3: </script>
¡¡
2 Òþ²Ø½Å±¾´úÂë
1: <script language="JavaScript">
2: <!--
3: document.write("Hello");
4: // -->
5: </script>
ÔÚ²»Ö§³ÖJavaScriptµÄä¯ÀÀÆ÷Öн«²»Ö´ÐÐÏà¹Ø´úÂë
3 ä¯ÀÀÆ÷²»Ö§³ÖµÄʱºòÏÔʾ
1: <noscript>
2: Hello to the non-JavaScript browser.
3: </noscript>
¡¡
4 Á´½ÓÍⲿ½Å±¾Îļþ
1: <script language="JavaScript" src="filename.js"></script>
5 ×¢Êͽű¾
1: // This is a comment
2: document.write("Hello"); // This is a comment
3: /*
4: All of this
5: is a comment
6: */
¡¡
6 Êä³öµ½ä¯ÀÀÆ÷
1: document.write("<strong>Hello</strong>");
¡¡
7 ¶¨Òå±äÁ¿
1: var myVariable = "some value";
¡¡
8 ×Ö·û´®Ïà¼Ó
1: var myString = "String1" + "String2";
¡¡
9 ×Ö·û´®ËÑË÷
1: <script language="JavaScript">
2: <!--
3: var myVariable = "Hello there";
4: var therePlace = myVariable.search("there");
5: document.write(therePlace);
6: // -->
7: </script>
¡¡
10 ×Ö·û´®Ìæ»»
1: thisVar.replace("Monday","Friday");
11 ¸ñʽ»¯×Ö´®
1: <script language="JavaScript">
2: <!--
3: var myVariable = 'Hello there";
4: document.write(myVariable.big() +
Ïà¹ØÎĵµ£º
À´Ô´£ºhttp://wanyij.blog.51cto.com/46570/43794
·¢ÏÖΪ±¾ÎÄÆðÒ»¸öºÏÊʵıêÌ⻹²»ÊÇÄÇôÈÝÒ×£¬ºÇºÇ£¬ËùÒÔÔÚ´ËÏÈ˵Ã÷ϱ¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´ ......
½ñÌìÁ˽âÁËÒ»µãjavascriptµÄ»ù´¡£¬¼ÇÏÂÀ´¹©ºóÐøÑ§Ï°·ÔÄ£º
Êý¾ÝÀàÐ͵ÄÅжϣºtypeof£¨var param£© ÅжϱäµÃÊý¾ÝÀàÐÍ
ä¯ÀÀÆ÷ÒÔ¼°²Ù×÷ϵͳµÄÅбð±äÁ¿ navigator.userAgent navigator.platform
var sUserAgent = navigator.userAgent;
//¼ì²âOpera¡¢KHTML
var isOpera = sUserAgent.indexOf(" ......
jQueryƬ¶Î£º
/*!
* jQuery JavaScript Library v1.3.2
* http://jquery.com/
*
* Copyright (c) 2009 John Resig
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
* Revision: 6246
*/
¡¡¡¡²é¿´ÈκÎÔ´ ......
·¢ÏÖΪ±¾ÎÄÆðÒ»¸öºÏÊʵıêÌ⻹²»ÊÇÄÇôÈÝÒ×£¬ºÇºÇ£¬ËùÒÔÔÚ´ËÏÈ˵Ã÷ϱ¾ÎĵÄÁ½¸öÄ¿µÄ£º
£¨1£©½éÉÜjavascriptÖеÄevalº¯ÊýµÄÓ÷¨
£¨2£©ÈçºÎÔÚº¯ÊýÄÚÖ´ÐÐÈ«¾Ö´úÂë
►ÏÈÀ´ËµevalµÄÓ÷¨£¬ÄÚÈݱȽϼòµ¥£¬ÊìϤµÄ¿ÉÒÔÌø¹ý¡£
evalº¯Êý½ÓÊÕÒ»¸ö²ÎÊýs£¬Èç¹ûs²»ÊÇ×Ö·û´®£¬ÔòÖ±½Ó·µ»Øs¡£·ñÔòÖ´ÐÐsÓï¾ä¡£Èç¹ûsÓï¾äÖ´Ðнá¹ûÊÇÒ»¸ö ......
ÔÚ±íµ¥Ìύǰ¾³£Óöµ½±íµ¥ÑéÖ¤ÎÊÌâ¶ø³£Óõķ½·¨ÓÐÒÔÏÂÁ½ÖÖ£º
1¡¢Ê¹ÓÃÌá½»°´Å¥Ìá½»£¬ÔÚform±íµ¥ÖеÄonsubmitʼþ½øÐÐ±íµ¥ÑéÖ¤£º
<script type="text/javascript">
& ......