Today is


JavaScript


What is JavaScript?  (Definition from Web definitions)

JavaScript is a scripting language developed by Netscape to enable Web authors to design interactive sites. Although it shares many of the features and structures of the full Java language, it was developed independently. Javascript can interact with HTML source code, enabling Web authors to spice up their sites with dynamic content. JavaScript is endorsed by a number of software companies and is an open language that anyone can use without purchasing a license. It is supported by recent browsers from Netscape and Microsoft, though Internet Explorer supports only a subset, which Microsoft calls Jscript.

Javascript is placed inline in the your html code using the following tags

<script language="javascript" type="text/javascript">

</script>

You can place your javascript code inside the two tags.

You can also place your javascript code in a separate external file if you thing that you will be reusing the same code in different pages.

 

Here javascript.js is the external javascript file name. If your file name is script.js you must replace javascript.js in the above code with script.js

When you are using an external javascript file, you can place the above code between the <head> tags like follows:

<head>

<script type="text/javascript" src="javascript.js"></script>

</head>

If you are using inline javascript code it can be placed between the head tags or inside the body tag. For example if you want to print something on the html page, you must place the code inside the <body> tags.

For eg, if you want to wish the user

<body>

<script type="text/javascript" language="javascript">

document.write ("Welcome to my site!!");

</script>

Some other content of the page

</body>

In the above code we can see that we are using document.write method, to display some output to our page. Here document is the current webpage we are updating and write is a method of the document object.

document - object and write is a method of the object document. semicolon in a statement in javascript code identifies the end of code. Javascript code is executed on client side before the page is completely loaded. Some of the old browsers will not support Javascript but most of the modern browsers have in built javascript support. So you may want some content only to be displayed if there is javascript support, you can do so using the <script> tag as given above.

Javascript can be used to display the dynamic date. Click here to see how


© 2005. All rights reserved.