JavaScript Background - HTML

JavaScript is the language of choice for the vast majority of scripting on the Web. It is supported by the two major browsers (Internet Explorer and Navigator), along with other varieties including StarOffice (www.staroffice.com) and Opera (www.opera.com). JavaScript is a relatively simple and powerful language, and is in broad enough use to make it the de facto standard for Web scripting languages.

However, using JavaScript does have a drawback. As long as there is more than one browser, there will be more than one way of doing things. Different developers keep up with industry standards and recommendations at different rates. The result is a mess for the lowly Web author who wants to do fun and exciting things with a Web page, but doesn’t want to limit their site to only those with the latest and greatest browser.

JavaScript is an object-oriented scripting language. With JavaScript, you can manipulate many variables and objects on your page. With JavaScript and the Document Object Model (DOM), you can change the value of all the properties of all the objects on your page. Because the DOM requires browsers to redraw pages in response to events, JavaScript becomes far more powerful with the DOM.

Java is the product of Sun Microsystems, which created it as a cross-platform, object-oriented programming language. JavaScript is a product of Netscape, which developed it to enableWeb developers to add programming functionality to Web pages.

JavaScript is the most widely used scripting language on the Web. Originally developed by Netscape, JavaScript has now grown beyond the realm of anything Netscape can control and is supported natively by all the major browsers. In conjunction with the DOM, you can use JavaScript to animate, display, or hide any part of your page, validate forms, and interact in other ways with the end user.

Note: A standardized version of JavaScript is defined by the European Computer Manufacturers Association (ECMA, at www.ecma.ch), which calls their language ECMAScript. Netscape turned JavaScript over to ECMA in an attempt to stabilize the language and make it more widely accessible to other developers. This has not prevented Netscape or Microsoft from continuing to make their own innovations and changes outside the standards created by the ECMA.

When combined with the DOM, you can do many things with JavaScript on a Web page, including the following:

  • Create a dynamic form displaying relevant fields, based on information already provided. For example, if a visitor answers yes to an insurance form question about whether any family members have died before age 55, a set of questions about which relatives and how they died would appear. If the answer is a no, the next question to appear might ask whether the visitor uses tobacco or illegal drugs. This helps to avoid such techniques as “If no, skip to question.”
  • Reward certain screen interactions, such as answering a series of trivia questions correctly, by providing a congratulatory animation. The JavaScript can both evaluate the results of the quiz and animate a still image (or a series of images) without reloading the page and without requiring additional actions by the visitor, such as clicking a “see results” button.
  • Sort the results of a database table based on the sort order requested by the visitor without additional server requests. Once receiving the information from the server, the client can sort the data in useful ways utilizing JavaScript and the DOM.

Even with all JavaScript can do, it has limitations. JavaScript is limited to its own sandbox within the browser. JavaScript cannot manipulate files on the client computer, including creating, writing, or deleting any system files. JavaScript also cannot execute any operations outside of the browser, including launching an installer or initiating a download.

These limitations may seem like a handicap for developers, but they help to safeguard site visitors. Right now, few Web citizens fear JavaScript; because of its built-in limitations it is not perceived as a security threat. This is unlike Java and ActiveX. Many visitors have disabled the capability for their browsers to accept any of those technologies for fear of rogue programs. JavaScript would do well to avoid any similar security scare, so some modest limitations are an acceptable price.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML Topics