JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create cookies, and much more.
JavaScript±»ÎÞÊýµÄÍøÒ³Ó¦ÓÃÓÚ¸ÄÉÆÉè¼Æ£¬ÑéÖ¤±íµ¥£¬¼ì²âä¯ÀÀÆ÷£¬´´½¨cookiesµÈ¡£
JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Mozilla, Firefox, Netscape, Opera.
JavaScriptÊÇ»¥Á¬ÍøÉÏ×î±»¹ã·ºÓ¦ÓõĽű¾ÓïÑÔ£¬ÊÊÓÃÓÚIE£¬Mozilla£¬Firefox£¬Netscape£¬OperaµÈÖÚ¶àÖ÷Á÷ä¯ÀÀÆ÷¡£
What You Should Already Know
ѧϰ»ù´¡
Before you continue you should have a basic understanding of the following:
ÔÚ½øÒ»²½Ñ§Ï°Ö®Ç°ÄãÓ¦¸ÃÏÈÁ˽âÏÂÃæµÄÕâЩ֪ʶ£º
If you want to study these subjects first, find the tutorials on our Home page.
Èç¹ûÄãÐèÒªÁ˽âÉÏÊöÄÚÈÝ£¬ÎÒÃǵÄÖ÷Ò³ÉÏÌṩÁËÏàÓ¦µÄ½Ì³ÌÁ´½Ó¡£
What is JavaScript?
ʲôÊÇJavaScript£¿
- JavaScript was designed to add interactivity to HTML pages
- JavaScriptΪHTMLÒ³ÃæÌṩ½»»¥µÄ¹¦ÄÜ¡£
- JavaScript is a scripting language (a scripting language is a lightweight programming language)
- JavaScriptÊÇÒ»Öֽű¾ÓïÑÔ£¨½Å±¾ÓïÑÔÊÇÒ»ÖֵͺijÌÐòÓïÑÔ£©
- A JavaScript consists of lines of executable computer code
- JavaScriptÊÇÒ»ÖÖÓÐÐòµÄ¼ÆËã»ú´úÂë¡£
- A JavaScript is usually embedded directly into HTML pages
- JavaScriptͨ³£Ö±½ÓǶÌ×ÔÚHTMLÒ³ÃæÖС£
- JavaScript is an interpreted language (means that scripts execute without preliminary compilation)
- JavaScriptÊÇÒ»ÖÖÚ¹ÊÍÐÔÓïÑÔ£¨¼´ÔÚÖ´Ðнű¾Ç°ÎÞÐè½øÐÐÔ¤ÏȱàÒ룩¡£
- Everyone can use JavaScript without purchasing a license
- JavaScriptÊÇÒ»ÖÖ¹«ÓÃÓïÑÔ¡£
Are Java and JavaScript the Same?
JavaºÍJavaScriptÊÇ·ñÒ»Ñù£¿
NO!
²»Ò»Ñù£¡
Java and JavaScript are two completely different languages in both concept and design!
JavaºÍJavaScriptÎÞÂÛ´Ó¸ÅÄî»òÊǽṹÀ´Ëµ¶¼ÊÇÍêÈ«²»Í¬µÄÁ½ÖÖÓïÑÔ£¡
Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++.
Java£¨ÓÉSun Microsystems¿ª·¢£©ÊÇÓëCºÍC++ͬÀàµÄÓïÑÔ£¬ËüµÄ¹¦ÄܸüÇ¿´ó£¬½á¹¹Ò²¸ü¸´ÔÓ¡£
What can a JavaScript Do?
JavaScriptÄÜ×öʲô£¿
- JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages
- JavaScriptΪHTMLʹÓÃÕßÌṩÁËÒ»ÖÖ³ÌÐò¹¤¾ß - HTMLʹÓÃÕßÒ»°ãûÓпÉÓõijÌÐò£¬µ«ÊǼ¸ºõËùÓÐÈ˶¼¿ÉÒÔÔÚ×Ô¼ºµÄHTMLÒ³Ãæ·ÅÈëһС¶ÎJacaScript´úÂ룬ÒòΪËüµÄÓï·¨Ï൱µÄ¼òµ¥¡£
- JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page
- JavaScript¿ÉÒÔΪHTMLÒ³ÃæÌí¼Ó¶¯Ì¬ÄÚÈÝ - document.write("<h1>" + name + "</h1>")ÕâÌõJavaScript¿ÉÒÔÏòÒ»¸öHTMLÒ³ÃæÐ´ÈëÒ»¸ö¶¯Ì¬µÄÄÚÈÝ¡£
- JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
- JavaScript¿ÉÒÔ±»Ê¼þ´¥·¢ - JavaScript¿ÉÒÔ±»ÉèÖÃΪµ±Ö¸¶¨Ê¼þ´¥·¢Ê±Ö´ÐУ¬ÀýÈçµ±Ò»¸öÒ³Ãæ¼ÓÔØÍê³Éʱ»òÊÇä¯ÀÀÕßµã»÷ÁËij¸öHTMLÔªËØ¡£
- JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element
- JavaScript¿ÉÒÔ»ñÈ¡»òдÈëHTMLÔªËØ - JavaScript¿ÉÒÔ»ñÈ¡ºÍÐÞ¸ÄHTMLÔªËØµÄÄÚÈÝ¡£
- JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server, this will save the server from extra processing
- JavaScript¿ÉÒÔУÑéÊý¾Ý - JavaScript¿ÉÒÔÔÚ±íµ¥Ìύǰ¶Ô±íµ¥Êý¾Ý½øÐÐУÑ飬Õâ¿ÉÒÔ¼õÇá·þÎñÆ÷µÄ¸ºµ£¡£
- JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser
- JavaScript¿ÉÒÔ¼ì²âä¯ÀÀÕßµÄä¯ÀÀÆ÷ - JavaScript¿ÉÒÔ¼ì²âä¯ÀÀÕßµÄä¯ÀÀÆ÷ÀàÐͲ¢ÎªÆä¼ÓÔØÏàÓ¦µÄÒ³Ãæ¡£
- JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer
- JavaScript¿ÉÒÔ´´½¨cookies - JavaScript¿ÉÒÔÔÚä¯ÀÀÕߵļÆËã»úÉÏ´æ´¢ºÍ´¦ÀíÐÅÏ¢¡£