Internet technologies/JavaScript/Home

From virtualMV2015wiki
Jump to: navigation, search


Icon Objectives.png

By the end of this page you will be able to:

  • Describe what JavaScript is.
  • Understand how JavaScript and HTML are related


JavaScript is a scripting programming language ( interpreted at run-time ) normally inserted in HTML code using the script tag and interacts with the Document Object Model (DOM) of the page. A simple "Hello world" using HTML and JavaScript could look like ..

    <script type="text/javascript">      <!--       document.write('<h4>Hello world.. JavaScript rulz!</h4>');    //-->    </script>  </body>

Which would display in a web browser like ...

Hello world.. JavaScript rulz!

Example :Click here to run the HTML/JavaScript

What is JavaScript?

  • JavaScript is a scripting language developed by Netscape around 1995 that is somewhat similar in capability to Microsoft’s Visual Basic, Sun’s Tcl, the UNIX-derived Perl, and IBM’s REXX.
  • JavaScript is primarily used in web browsers to add client-side interactivity such as: automatically include today’s date on a Web page, make a linked-to page to appear in a popup window, make text or a graphic image change during a mouse rollover, validate form information and check a user’s computer set-up (e.g. to check whether they have a plug-in installed), plus can add "fun" interactive elements to a web page..
  • In general, scripting languages are easier and faster to code in than the more structured and compiled languages such as C and C++. Script languages generally take longer to process than compiled languages, but are very useful for shorter programs.
  • JavaScript code can be imbedded in HTML pages and interpreted by the Web browser (or client). JavaScript can also be run at the server as in Microsoft’s Active Server Pages (ASPs) before the page is sent to the requestor. Most modern web browsers support JavaScript (including those on some mobile devices), but sometimes in slightly different ways.
  • The web browser provides a host environment for client-side computation including, for instance, objects that represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output.
  • JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation. For example, you can write a JavaScript function to verify that users enter valid information into a form requesting a telephone number or zip code. Without any network transmission, the HTML page with embedded JavaScript can check the entered data and alert the user with a dialog box if the input is invalid.
  • JavaScript is very different to Sun's Java. Java is a fully fledged programming language (like Microsoft's Visual C# or VisualBasic ), and is designed to be platform independent (runs on Windows, Unix, MocOS).
  • JavaScript is one dialect of ECMAScript (ECMA-262). Others include Adobe ActionScript, and Microsoft's JScript.
  • JavaScript has become very popular as a part of AJAX (asynchronous JavaScript and XML), which gives a Web browser the ability to retrieve data from a Web Server without having to refresh the entire page. Google used this extensively when it introduced Gmail in 2004 and Google maps (2005).


  • JavaScript is
    • a scripting language (executed at runtime)
    • a lightweight programming language
    • lines of executable computer code
    • instructions that can be inserted into an HTML page and interact with the Document Object Model (DOM) of the page
    • an open scripting language that anyone can use without purchasing a license
    • supported by all major browsers like Internet Explorer, Firefox, Chrome & Safari.
    • part of a family of technologies used for HTML5 (HTML/CSS/JavaScript)
    • a language that uses object oriented concepts, it is not a true object oriented environment
      • All javascript components are objects (things that do something specific and can be changed)
        e.g. Document object (visible web page) you can modify size, color, text using JavaScript


document.write('<h1>Hello world.. JavaScript rulz!</h1>');;
<input type="button" name="Submit" value="Submit" onClick="fnCheckOK()" />

Icon References.png References