Javascript

Mar 4, 2015   Allumez   Web Hosting

Taking about JavaScript’s origin, it was released by Netscape and Sun Microsystems in 1995. JavaScript and Java both are different things.

    What is JavaScript

  1. It is a programming language.

  2. It is an interpreted and object-based programming language.

  3. It is widely used and supported

  4. It is easy to get to to the beginner.

Uses of JavaScript

  1. Javascript is used to add multimedia elements

With JavaScript we can show, change, resize images, hide and

create image rollovers. We can create scrolling text across the status

bar.

  1. Interact with the user

It can do some processing of forms and can corroborate user input when the user submits the form.

Writing JavaScript

 JavaScript code is characteristically implanted in the HTML, to be interpreted and run by the client's browser. Here are some tips to remember while writing JavaScript commands.

  1. JavaScript code is case sensitive.

  2. White space between words and tabs are ignored.

  3. Line breaks are ignored except within a statement.

  4. JavaScript statements end with a semi- colon ( ; ) .

The SCRIPT Tag

The <SCRIPT> tag prepares a browser that JavaScript code follows. It is embedded in the HTML.

<SCRIPT language = "JavaScript">

Statements

</SCRIPT>

SCRIPT Example

  1. Open "script_tag.html" in a browser.

  2. View the Source

  3. Put the cursor after <! – Enter code below and enter the following:

<SCRIPT language = "JavaScript">

alert("Welcome to the script tag test page.")

</SCRIPT>

5

  1. Save the changes by choosing Save from the File menu.

  2. After that Refresh the browser by clicking the Refresh or Reload button.

Implementing JavaScript

There are three ways to add JavaScript commands to our Web Pages.

1) Embedding code

2) Inline code

3) External file

External File

You can use the SRC attribute of the <SCRIPT> tag to call JavaScript code

from an external text file. This is useful if you have a lot of code or you

want to run it from several pages, because any number of pages can call the

same external JavaScript file. The text file itself contains no HTML tags. It

is call by the following tag:

<SCRIPT SRC="filename.js">

</SCRIPT>

External Example

• Open "external.html" in a browser

• View the Source

• Put the cursor after <! – Enter code here 􀃆 and enter:

<SCRIPT language = "JavaScript" SRC = "external.js">

</SCRIPT>

• Save the changes and refresh the browser.


Share this post

We are always here to help. If you have a query Send Now