Javascript is used to make web pages interactive, validate forms, detect web browsers, create cookies and more.
Before you begin learning javascript, you should should already have at least a basic understanding of HTML/XHTML.
What is javascript?
Javascript is a scripting language that was designed to add interactivity to web pages. Javascript
consists of lines of executable code that can be emedded directly into HTML web pages and is also
an interpreted language, which means that scripts are executed without preliminary compilation.
Javascript is free for everyone to use.
Javascript can be embedded into web pages using the openning and closing <script> </script> tags. The javascript statements that are included within the <script> tags are executed when the web page loads in a web browser.
The <script> tags can be embedded within the <head> or <body> tags, which tell the web browser where the javascript starts and ends. A single web page can have several sets of openning and closing <script> tags.
how to embed javascript into an HTML file
This tutorial shows you how to javascript into an HTML file.
how to write text with javascript
This tutorial shows you how to write text with javascript using the "document.write" command.
how to add HTML tags to javascript
This tutorial shows you how to add HTML tags to javascript.
how to add comments to javascript code
This tutorial shows you how to add comments that will not be displayed on web browsers in javascript.
how to link to an external javascript file
This tutorial shows you how to link to an external javascript file.
Javascript that is placed in the header of a web page between the <head> tags is loaded before the function is called. Javascripts in the header are executed when they are called or when an event is triggered.
Javascript that is place within the openning and closing <body> tags are executed when the web page loads and generates as part of the content of the web page.
how to place javascript in the header of a web page
This tutorial shows you how to place javascript in the header of a web page.
how to place javascript in the body of a web page
This tutorial shows you how to place javascript in the body of a web page.
Javascript is a sequence of javascript statements that are executed by the web browser. A javascript statement is a command that tells the web browser what to do. For example, the javascript statement "document.write("I am learning javascript");" tells the web browser to write the text "I am learning javascript".
According to the javascript standard, it is optional whether or not to place a semicolon at the end of a javascript statement, however, it is common practice to include a semicolon at the end of executable statements.
Also, the use of semicolons allow for the multiple statements to be written on one line.
Javascript statement can be grouped together in javascript blocks. A javascript block starts with a left curly bracket ({) and ends with a right curly bracket (}). A javascript block is used to make a sequence of javascript statements within the javascript block execute together.
For example, the javascript code below is an example of a javascript block that will write a header and a paragraph to a web page.
<script type="text/javascript">
{
document.write("<h1>This is a header</h1>");
document.write("<p>This is a paragraph</p>");
}
</script>