Thursday 28 February 2013

JavaScript Overview


Control the appearance of elements on your web page

Every web page is a collection of several individual elements which are called objects like an image, a link etc.
JavaScript is capable of controlling the appearance of many objects. For example you can open new pages in customized windows where you can specify their size, determine whether they have scroll bars or not etc.

JavaScript responds user actions on your web pages

JavaScript can control objects on web pages in response to various actions taken by the user which is called event. For example display a dialog box when an user clicks on a button, opening a new page, mouse over on a link to change the appearance of the link or control the background color of your web pages.

Display various date time format

JavaScript has the ability to retrieve the date and time of your computer's clock and it is enable to display various formatting of date-time through it's internal date object.

Perform calculations

JavaScript can perform wide variety of mathematical calculations. It has a library of all the mathematical constants and functions needed. These functions can be applied in different ways, for example an online financial transaction where JavaScript can be used to calculate subtotal, total etc, or an online calculator or creating games and interactive simulations with advance math functions such as sine and cosine.

Validate forms data

JavaScript can be used to validate form data including names, addresses, URL, email addresses, phone numbers, zip codes etc. in html forms before sending the data to a server. If you want to validate the said data in server side you have to wait while the information is sent up to the server for checking, using JavaScript you can detect the error and prompt the user immediately.

Create Cookies

cookie is a mechanism in a web browser where a simple text sent to the visitors' computer. As it is a piece of text, cookies are not executable. JavaSript can store information from this piece of text on visitor's computer and reuse it automatically next time the user visits the same page.

Detect the visitor's browser

Sometimes it is difficult to create pages that are displayed identical on different browsers or even operating systems. JavaScript can detect the visitor's browser and load the appropriate page for that specific browser.

Dynamic HTML

Dynamic HTML, or DHTML, is a collection of technologies used together to make interactive and animated web site by using a combination of JavaScript, HTML, DOM (Document object module) and CSS
photo credit: niecieden. Photo is used under creative Common License.

JavaScript and the ECMA

JavaScript is a cross-platform, object-oriented scripting language developed by Netscape was first used in Netscape browsers. However, Netscape was working with European Computer Manufacturers Association (ECMA) to deliver a standardized, international programming language based on core JavaScript. ECMA is an international standards association for information and communication systems. This standardized version of JavaScript, called ECMAScript, behaves the same way in all applications that support the standard. Companies can use the open standard language to develop their implementation of JavaScript. The first version of the ECMA standard was documented in the ECMA-262 specification. The ECMA-262 standard is also approved by the ISO (International Organization for Standardization) as ISO-16262.

The following table describes the relationship between JavaScript and ECMA versions.

JavaScript versionRelationship to ECMA version
JavaScript 1.1ECMA-262 is based on JavaScript 1.1.
JavaScript 1.2ECMA-262 was not complete when JavaScript 1.2 was released. JavaScript 1.2 is not fully compatible with ECMA-262 for the following reasons:

Netscape developed additional features in JavaScript 1.2 that were not considered for ECMA-262.

ECMA-262 adds two new features: internationalization using Unicode, and uniform behavior across all platforms. Several features of JavaScript 1.2, such as the Date object, were platform-dependent and used platform-specific behavior.
JavaScript 1.3JavaScript 1.3 is fully compatible with ECMA-262.

JavaScript 1.3 resolved the inconsistencies that JavaScript 1.2 had with ECMA-262, while keeping all the additional features of JavaScript 1.2 except == and !=, which were changed to conform with ECMA-262. These additional features, including some new features of JavaScript 1.3 that are not part of ECMA, are under consideration for the second version of the ECMA specification.
For example, JavaScript 1.2 and 1.3 support regular expressions, which are not included in ECMA-262. The second version of the ECMA specification had not been finalized when JavaScript 1.3 was released.
JavaScript 1.4 (Works on Netscape server only)
JavaScript 1.5JavaScript 1.5 is compatible with ECMA-262 Edition 3. This is a major update as per as security and libraries are concern. Better compatibility with modern browser is another important aspect of it.

JavaScript version and supported browser versions

The following table covers the Javascript versions, release date and supported browser versions.
VersionRelease dateNetscape
Navigator
Mozilla
Firefox
Internet
Explorer
OperaSafariGoogle
Chrome
1.0March 19962.03.0
1.1August 19963.0
1.2June 19974.0-4.05
1.3October 19984.06-4.74.0
1.4Netscape
Server
1.5November 20006.01.05.5
6.0
7.0
8.0
6.0
7.0
8.0
9.0
10.0
3.0
3.1
3.2
4.0
1.0
1.6November 20051.5
1.7October 20062.06
1.8June 20083.0
1.8.13.5
1.8.2June 22, 20093.6

Test JavaScript Version

The following web document returns the version of Javascript supported by your browser.

HTML Code

  1. <!DOCTYPE html>  
  2. <head>  
  3. <meta charset="utf-8" />  
  4. <title>JavaScript version checking</title>  
  5. </head>  
  6. <body>  
  7. <h1 style="color: red">JavaScript version checking</h1>  
  8. <hr />  
  9. <script type="text/javascript">  
  10. var jsbrowver = 1.0;  
  11. </script>  
  12. <script language='Javascript1.1'>  
  13. var jsbrowver = 1.1;  
  14. </script>  
  15. <script language='Javascript1.2'>  
  16. var jsbrowver = 1.2;  
  17. </script>  
  18. <script language='Javascript1.3'>  
  19. var jsbrowver = 1.3;  
  20. </script>  
  21. <script language='Javascript1.4'>  
  22. var jsbrowver = 1.4;  
  23. </script>  
  24. <script language='Javascript1.5'>  
  25. var jsbrowver = 1.5;  
  26. </script>  
  27. <script language='Javascript1.6'>  
  28. var jsbrowver = 1.6;  
  29. </script>  
  30. <script language='Javascript1.7'>  
  31. var jsbrowver = 1.7;  
  32. </script>  
  33. <script language='Javascript1.8'>  
  34. var jsbrowver = 1.8;  
  35. </script>  
  36. <script type='text/javascript'>  
  37. alert('Supported Javascript Version : ' + jsbrowver);  
  38. </script>   
  39. </body>  
  40. </html>  
photo credit: mattjerome_88. Photo is used under creative Common License.

No comments:

Post a Comment