Welcome to www.programmer2programmer.net Its all about programming


Programmer 2 Programmer

 Security Tips
 SQL Injection
 Encryption & Decryption
 Password Recovery
  
 Tips
 Connection Strings
 Interview Question
 Microsoft Certification
  
 LIVE Project
 Project #1
 Project #2
  
 Web Development
 HTML
 DHTML
 CSS
  
 Scripting
 Java Script
 VB Script
  
 Web Programming
 Cold Fusion
  
 Site Map
 Site Map
  
One stop solution for VB6, VB.Net, C#, ASP.Net, Crystal Report, Oracle, SQL Server, MySql, PHP, XML, AJAX ....
Home Personal Member Forum Source Project Tips Contact  
 

 

Java Script

 

What is Java Script?

JavaScript is an object-based scripting language designed primarily for HTML (Hypertext Markup Language), It supports both IE (internet Explorer) and Netscape Navigator and all other major web browser. Java script can be used for both client side as well as server side in web development. It is not a programming language it can not create executable code while compiling, it is embed in document and while pursing the html document it executes the script, it is an object-based scripting language, while reasonably simple in syntax, construction, and features, the object-based nature of JavaScript still offers programmers significant power and flexibility through the ability to create functions and new objects.

1. What is Java Script

2. Java Script Syntax
3. Java Script Objects
4. Java Script Sample Code
5. Java Script FAQ
 
 
 
An object in the context of JavaScript, is a collection of properties and methods consisting a set of defined characteristics that you can view and modify, and which you can interact. Methods are the techniques that are used to perform action involving objects and properties. For example statement like Document. Write("Welcome to Javascript") here Document is the object, Write is the method of Document object, JavaScript follows event driven sequence. the events determine the program flow and event handlers determine what happen when these event occurs.

Where to Write Java Script
You can write javascript in body or head section depend on your requirement or you can write java script in a sepeate file with extension ".js" and includes it in your HTML document with <SCRIPT SOURCE="abc.js"> tag.

1. Writing text on the browser window 
<html>
<body>
<script language="JavaScript">
document.write("Hello World!")
</script>
</body>
</html>

2. Writing Formatted Text on the Browser 
<html>
<body>
<script language="Java Script">
document.write("<h1>Hello World!</h1>")
</script>
</body>
</html>

3. Using HEAD Section
<html>
<head>
<script language="JavaScript">
function message(){ 
alert("This alert box was called with the onload event") 
}
</script>
</head>
<body onload="message()">
</body>
</html>

4. Using BODY Section 
<html>
<head>
</head>
<body>
<script language="JavaScript">
document.write("This message is written when the page loads")
</script>
</body>
</html>
<!--Example E Using External script -->
<html>
<head>
</head>
<body>
<script src="myscript.js">
</script>
<p>The actual script is in an external script file called "myscript.js".</p>
</body>
</html>

Try yourself.
1. Load any text editor (Notepad, WordPad, Word, TextPlus)
2. Create the HTML file and save it, with .HTM or .HTML extension. and write following HTML and javascrpt.
   <html>
   <body>
   <script language="JavaScript">
   document.write("Hello to JavaScript World!")
   </script>
   </body>
   </html>
3. Open saved file in Browser (IE, Netscape) to view it will display Hello to JavaScript World!.

Java Script Resource
1. www.w3.org
2. www.w3school.com


 2. Java Script Syntax


(C) Atanu Maity, 2006-2007