![]() |
JavaScript For Beginners
JavaScript is the scripting language and is used for the web. It is used webpages for validating forms,adding different functionalities , for detecting different browsers and creating cookies. One can also improve the design of web page using JavaScript. With the help of JavaScript one can work on any browser.Before working with JavaScript it necessary to know HTML and also XHTML. JavaScript is an interpreted language and so is directly used in HTML pages.
Let us start working with JavaScript. For example in the code below we have start with JavaScript. HTML Code:
<html>When we write <script type="text/javascript"> it means we are using JavaScript in the program. To start with JavaScript you have to insert this tag and to end you need to write </script> document.write is for giving the out put.You need to write this command in between this tags <script> and </script> so that browser will accept it as a JavaScript command and then execute it. When one places a script in head section it gets loaded and then gets executed when it is called.In following way it is written to place in head section HTML Code:
<html>HTML Code:
<html>HTML Code:
<html>You have to write that code program in external file and save it as .js extension.You can place it in following way HTML Code:
<script src="abc.js"> </script>Statements in Javascript are written in following way HTML Code:
<script type="text/javascript">HTML Code:
<script type="text/javascript">For example HTML Code:
// This statement is for header:First let us start with if statement. if statement is executed when condition is true. The syntax is as follows Let us see an example HTML Code:
<script type="text/javascript">HTML Code:
<script type="text/javascript">In If...else Statement ( if statement is executed when condition is true and else will be executed when condition is not true.) The syntax is as follows Let us see an example HTML Code:
if (salary < 100000) Now let us discuss about loops in Javascript 1. For loop 2. While loop 1. For loop :- This loop is used when you know how many times the script has to be executed. Syntax Example HTML Code:
<html>While loop The while loop is used when you want the loop to execute and continue executing while the specified condition is true. Syntax while (var<=endvalue) Example HTML Code:
<html> |
Re: JavaScript For Beginners
nice info. wats the difference b/w placing the <script> Part in <head> section and <body> section. What happens? can we see any difference while executing?
|
Re: JavaScript For Beginners
Quote:
|
Re: JavaScript For Beginners
Then why do we use it in different sections. which is the script's default standard.
|
Re: JavaScript For Beginners
At time you cannot and should not link in the head.
Say for example on some pages I need to include some script I put in the body but for all pages inclusion I put it in header. This is what I follow here and may not be actually true. |
Re: JavaScript For Beginners
|
Re: JavaScript For Beginners
Thanks for share it. Some place I not able to understand.
|
Re: JavaScript For Beginners
Quote:
|
Re: JavaScript For Beginners
Great basic stuff. Why not continue this tutorial.
I suggest moving onto simple site browsing effects such as: mouse over effects. 1 question though: Quote:
For i = 0 to 10 step 1 as in increment in ones? Would the loop excecute correctly if I don't enter the "i++" part? Thank you |
Re: JavaScript For Beginners
Quote:
|
| All times are GMT +5.5. The time now is 22:15. |