Article Categories
Advertisement
Article Options
Popular Articles
  1. Manage your MySpace Calendar
  2. Carbon Fibre
  3. How to add Photos to MySpace
  4. Animated Mask Using Flash
  5. The Advantages of PHP
No popular articles found.
Popular Authors
  1. Joseph Lancaster
  2. Nicholas Hall
  3. Adam Carmichael
  4. Celeste Stewart
  5. Deepaq Sharma
  6. Katerina Mitrou
  7. Arnab Ghosh
  8. Gregg Hall
  9. Robby Alientjuh
  10. Kevin Yank
No popular authors found.
 »  Home  »  Web Development  »  Javascript Defined
Javascript Defined
By Celeste Stewart | Published  03/29/2006 | Web Development | Rating:
Javascript Defined
JavaScript is a language that creates programs that run within a web browser. It is not related to Java, a product from Sun Microsystems. In fact, the only similarity between JavaScript and Java is the name. Netscape created JavaScript and introduced it as LiveScript with the release of Netscape Navigator 2.0 in 1995 and soon changed the name to JavaScript.

JavaScript programs and scripts are embedded directly into the HTML. When a user’s browser opens the HTML file, the script executes. JavaScript is commonly used to make interactive mouse rollovers where when the mouse moves over a portion of the screen, something happens such as text appears, the computer beeps, an alternate image is displayed. Another common use is to pop up a dialogue box or alert. JavaScript can make calculations, add effects, create passwords and much more.

The beauty of JavaScript for programmers is the ability to add a touch of interactivity to webpages without the use of plug-ins, Java or CGI. Using JavaScript doesn’t require advanced programming knowledge or a large time investment either.

The trouble with JavaScript lies in the fact that each new release of Netscape’s Navigator uses a different version of JavaScript. On top of that, Microsoft came up with their own scripting language called JScript which is not completely compatible with JavaScript. In the early days of JavaScripting, this created a challenge for developers using JavaScript; they had to identify the browser and the version of the browser being used, write several different versions of the script and output the correct script for the browser in use. Microsoft and Netscape have recently agreed to create and abide by scripting standards in the future. JavaScript is now supported by Microsoft Internet Explorer 3.0 and above as well as any browser that has licensed JavaScript interpreter such as Opera.

JavaScript conforms to the European Computer Manufacturers Association (ECMA) scripting protocols as its baseline for functionality. ECMAScript is the core of JavaScript. ECMAScript describes syntax, types, statements, keywords, reserved words, operators and objects.

JavaScript also follows the Document Object Model or DOM which is an application programming interface for both HTML and XML. DOM describes methods and interfaces for working with a webpage’s contents.

In addition, the final model JavaScript uses is the Browser Object Model or BOM for interacting with the web browser. BOM allows the developer to manipulate the browser window and frames. Among BOM’s capabilities are the ability to pop up new windows, resize or close browser windows, provide detailed information about the page loaded and the screen resolution, support cookies and more. BOM is not standardized and each browser has its own implementation.

What does a JavaScript look like? Here’s a simple piece of script for a message box that displays text a user has entered. In between the HEAD tags, introduce the SCRIPT tags as shown below:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript –
Include the JavaScript functions and close the SCRIPT tag, in our case:
function TextBox (textstring) {alert (textstring) }
// - End of JavaScript - -->
</SCRIPT>
</HEAD>
Next, position the FORM tags within the body of the page as shown below:
<BODY>
<FORM>
<INPUT NAME="text" TYPE=Text size=“30”>
<INPUT NAME="submit" TYPE=Button VALUE="Hit it!" onClick="TextBox(form.text.value)">
</FORM>
</BODY>
</HTML>

This simple script will then display an alert box with whatever text the user has entered into the text box. Notice how easily the script is entered into the HTML? No fancy software or complicated programming required, just a little bit of knowledge about the various variables and commands.

In addition, the internet has thousands of free JavaScripts available that others have already created. Simply search the internet using the keywords, “free JavaScripts” and then copy and paste the desired scripts into the HTML.

JavaScript may have a complicated background with its alphabet soup of core technologies such as ECMA, DOM and BOM but it is simple to use and execute.

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Spread The Word

del.icio.us it Digg this Furl Reddit Yahoo! this!



Get updates in your E-mail - Get notified when new articles are added, and get exclusive offers from our partners!
E-mail Address:
Subscribe: UnSubscribe: