Javascript


Related applications


Search a word:
   



© The scientific sentence. 2010


Introduction



1. Preface


JavaScript's official name is ECMAScript. The standard is 
developed and maintained by the ECMA organisation. It was 
invented by Brendan Eich at Netscape (with Navigator 2.0). 

JavaScript was designed to add interactivity to HTML pages.
It is a scripting language, embedded directly into HTML pages.
Javascript is an interpreted language (that is scripts are 
executed  directly without y compilation). That's the browser 
that executes Javascripts commands.

2. Browser and Javascript


The browser recognizes a JavaScript command and execute it 
by:
<script type="text/javascript">
</script>

<html>
<body>
<script type="text/javascript">
document.write("Regards");
document.write("<h1>Regards ..</h1>");
</script>
</body>
</html>

The code above will produce this output on an HTML page:
Regards
<h1>Regards ..</h1>

The two above lines can be grouped in one block between two
curly brackets {}, if we want to execute them not separatly.

3. Comments

Browsers that do not support JavaScript will display JavaScript 
as page text. To prevent this, we "hide" the JavaScript code with 
the HTML comment tags  <!--  and  --> 
<script type="text/javascript">
<!--
document.write("Regards");
//-->
</script>

The two forward slashes (//) prevent JavaScript from 
executing the --> tag.


JavaScript Comments are:
 //: for a single line comments
 /*
 ... 
 */: for multiple line comments 
 

4. Where to put the scripts?


We can place an unlimited number of scripts inside a 
document, in both the body and the head section.

We place the javascript scripts in the body section when 
the scripts in a page will be executed immediately while 
the page loads into the browser.

We place it inside the head section when the scripts will 
be executed if called. It is always loaded before to be used, 
ready for any trigger. 

<html>
<head>
<script type="text/javascript">
....
</script>
</head>

5. External JavaScript file.js


To run JavaScript on several pages, we can write a JavaScript code 
in an external file, save it as your_file.js file with a .js file 
extension.

We call this file from another page in the head section as follows:
<head>
<script src="your_file.js"></script>
</head>

  
Google
Web
ScientificSentence
 




chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.