Basic JavaScript

0
14

What is JavaScript?

JavaScript is a script language – a system of programming codes, created by Netscape, that can be embedded into the HTML of a web page to add functionality. JavaScript should not be confused with the Java programming language. In general, script languages ​​such as JavaScript are easier and faster to code than more structured languages ​​such as Java and C ++.

JavaScript is client-based, which means it does not have to make any server requests to run. This makes it ideal for fast response and initial validation of form input.

When combined with CSS, JavaScript can create dynamic effects using Dynamic HTML.

JavaScript is event driven, meaning it acts on events that happen on the screen such as clicking a button.

JavaScript is normally inserted into the HEAD section of the web page surrounded by a (SCRIPT) tag. It is generally called from the HTML in the web page BODY in response to an event, such as a mouse click. JavaScript can also be inserted directly into the BODY section of the web page.

Here are some basic scripts that may come in useful. Modify and experiment with them

A pop up window

(HTML)

(HEAD)

(TITLE) Opening a pop-up window (/ TITLE)

(SCRIPT LANGUAGE = "JavaScript")

function popupwin () {

winpopup = window.open ( "", "popup", "height = 300, width = 400");

winpopup. [removed] ( '(HTML) n (HEAD) n');

winpopup. [removed] ( '(TITLE) This is a popup window (/ TITLE)');

winpopup. [removed] ( '(/ HEADn (BODY) n');

winpopup. [removed] ( '(FORM NAME = "otherform") n');

winpopup. [removed] ( '(INPUT VALUE = "Close Window") n');

winpopup. [removed] ( '(/ FORM) n (/ BODY) n (/ HTML)');

winpopup.document.bg)

return;

}

(/ SCRIPT)

(/ HEAD)

(BODY)

(H1) JavaScript Pop-up Window (/ H1)

(P)

(FORM NAME = "form")

Please CLICK here to open a popup:

(INPUT VALUE = "Open a Pop-up window")

(/ FORM)

(BODY)

(/ HTML)

Drop down menu link

(HTML)

(HEAD)

(TITLE) Opening a pop-up window (/ TITLE)

(/ HEAD)

(BODY)

(H1) Drop Down Menu Link (/ H1)

(FORM)

(SELECT NAME = "menu")

(OPTION VALUE = "http://google.com") Google (/ OPTION)

(OPTION VALUE = "http://yahoo.com") Yahoo (/ OPTION)

(OPTION VALUE = "http://ca-development.co.uk") CA-Development (/ OPTION)

(/ SELECT)

(Input type = "button" value = "Take me there")

(/ FORM)

(BODY)

(/ HTML)

Alert box

(HTML)

(HEAD)

(TITLE) Alert Box (/ TITLE)

(/ HEAD)

(BODY)

(SCRIPT LANGUAGE = "JavaScript")

alert ( "Welcome make yourself at home");

(/ SCRIPT)

(/ BODY)

(/ HTML)

Source

Leave a Reply