Home arrow JavaScript arrow Introduction to JavaScript
Introduction to JavaScript PDF
Friday, 23 November 2012
work in progress...

JavaScript is an object oriented scripting language that is supported by modern browsers very usefull at enhancing user interface within your browser. Also it is used to create dynamic web sites.

Example 1. Run  JavaScript code from a html file

Let's see a first example which will display a string in your browser:

<head><title>Example 1</title></head>

    <script type="text/javascript">
      document.write("This is a string.");

Example 2. Run JavaScript from an external file

This is most common use/placement of a JavaScript. We will have two files, example2.html which will be our web page and a separate file (myscript.js for this example) which will be our JavaScript script:

  <title>Example 2. Runing a JS script from outside file</title>
  <script type="text/javascript" src="myscript.js"></script>

  <p id="displayString"></p>

And the script file is:

window.onload = echoString;
 function echoString() {
  document.getElementById("displayString").innerHTML = "This is\
    just another string"

Last Updated ( Saturday, 24 November 2012 )
< Prev

Other BSD Systems





Best BSD firewall?