How to run javascript ?

The Software Tools

The best way to learn JavaScript is to type the HTML and scripting code into documents in a text editor.  The other component that is required for learning JavaScript is the browser.  You don’t have to be connected to the Internet to test your scripts in the browser.  You can perform all testing offline.  This means you can learn JavaScript and create cool, scripted Web pages with a laptop computer-on a boat in the middle of an ocean.

What your first script will do

We begin by considering a script (or program) that displays the text “This is my JavaScript page” in a body of an HTML  document.  The internet explorer web browser contains a JavaScript interpreter, which processers the commands written in JavaScript.  The JavaScript code and its output are shown below

<head> <title> MY SCRIPT </title>
<font size = “5”>
<script type = “text/javascript”>
Document.write (“Hello World”)


If you encounter an error in your first attempt at loading this document into your browser, go back to the text editor and check the lines of the script section, looking carefully at each line.  There may be a single character  out of place, a lowercase letter where an uppercase one belongs, or a quote or parenthesis missing.  Make necessary repairs, switch to your browser, and click Reload.

To see how dynamic the script in test.html is, go back into the text editor and replace the word “world” with “Friend “ Save, switch, and reload to see how the script changes the text in the document.  Feel free to substitute other text for the quoted text in the document.  Write()statement. Or, add more text with additional document.write()statements.  Always be sure to save, switch , and reload to see the results of your handiwork.

The above program illustrates several important JavaScript features.  The JavaScript code is written in the <body> of HTML document.  The <script> tab indicates to the browser that the text which follows is part of a script.  The type attribute specifies the type of file as well as  the scripting language used in the script in this case, a text file written in JavaScript.

The syntax of JavaScript as follows:

<script type = “text/javascript>
<!- -script code here- ->


Both the Internet explorer and Netscape Navigator use JavaScript as the default scripting language.

Some browser do not support the <script> …</script> tags.  If your document is to be rendered with such browsers, enclose the script code between these tags in an HTML comment, so that the script text does not get displayed as part of the web page.

Document.writein(“Hello World!”)

  • Always include a semicolon at the end of a statement to terminate the statement.  This notation clarifies where one statement ends and the next statements begin

This line uses the browser’s document object, which represents document the browser is currently displaying.  The document object allows a script programmer to specify text to display in the HTML document.

An object resides in the computer’s memory and contains information used by the script.  The term object normally implies that attributes (data) behaviours (methods) are associated with the object.  The object’s methods use the attribute’s data to perform useful actions for the client of the object.  (i.e. the script that calls the methods) A method may require additional information (arguments) to perform its action.  This information is enclosed in parentheses after the name of the method in the script.  In above line, the document object’s write.  In method is called to write a line of markup in the HTML document.

  • Forgetting the ending </script> tag for a script may prevent the browser from interpreting the script properly and many prevent  the  HTML document from loading properly.

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Get Alert

    Enter your email address:

  • Categories

  • Twitter

Subscribe Now!
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.

Subscribe Here

Popup Dialog Box Powered By :
  • RSS
  • Facebook
  • Google+
  • Twitter