Home > Main > JavaScript

JavaScript


2008 October 02 | 05:14 pm

Introduction

JavaScript is a widely used tool for web scripting, and was originally developed by the Netscape Communications Corporation under the name LiveScript. One of JavaScript's most prevalent uses is in AJAX (Asynchronous JavaScript And XML) applications. AJAX is one of the principle technologies behind DHTML, a technology used for dynamically editing a web page after it has been delivered to a user's browser.

Features

JavaScript, like it's similarly named cousin Java, inherits much of it's syntax from the C programming language. As is the case with most scripting languages, JavaScript is weakly-typed. This means that one variable could be used to hold an integer value, then a string value, and so on, without the casting necessary in strongly-typed languages like C#.

Drawbacks

Perhaps one of the biggest concerns with JavaScript is the frequency with which the applications written in it are exploited. Of course, this is probably more due to programmer error than inherent susceptibility to exploits. Another concern arises if a website depends too much on JavaScript for such things as navigation and/or form validation. Given that JavaScript exploits are so common, many advanced users disable JavaScript in their browsers. My biggest gripe stems from the fact that not all browsers implement the same version of JavaScript, Safari (from Apple, Inc.) being the worst offender.

Notes

To use JavaScript in a web page, it must be embedded in that page or linked in the head of the document. Which method you choose depends on how your script executes. Some examples follow.

• samplepage.html. JavaScript linked in document head.

<html>
<head>
<title>Page Title Goes Here</title>
<script type=text/javascript src=js/script-one.js></script>
</head>
<body>

</body>
</html>

• samplepage.html. JavaScript embedded in document.

<html>
<head>
<title>Page Title Goes Here</title>
</head>
<body>

<script type=text/javascript>
...
</script>


</body>
</html>

As you can see, there is a <script> HTML tag we use for adding JavaScript to our page. This tag isn't limited to just JavaScript, however. You may also specify EMCAScript (the official standard on which JavaScript is based) and VBScript. Also, you will notice that <script> tags linked in the head of the document require an extra src attribute, where we specify the URL to where the external script is stored.


Updated: 2008 October 23 | 11:57 pm

Tags: JavaScript, Code, Scripting

Back to top Comments ( 0 ) • Login to comment.

Sorry. There are currently no comments for this article.

Home > Main > JavaScript