Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
24 views

Introduction To Java Script

JavaScript is a scripting language that is commonly used to add interactivity to web pages and is included in HTML documents using <script> tags; it can be placed in the <head> or <body> of a document and is executed as the page loads. JavaScript borrows syntax from Java but is not the same as Java and can be used to modify elements, handle events like clicks, and validate forms.

Uploaded by

gurusodhii
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Introduction To Java Script

JavaScript is a scripting language that is commonly used to add interactivity to web pages and is included in HTML documents using <script> tags; it can be placed in the <head> or <body> of a document and is executed as the page loads. JavaScript borrows syntax from Java but is not the same as Java and can be used to modify elements, handle events like clicks, and validate forms.

Uploaded by

gurusodhii
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction to Java Script

About JavaScript

JavaScript is not Java


The original name for JavaScript was LiveScript Its syntax resembles java syntax The name was changed when Java became popular

Statements in JavaScript resemble statements in Java, because both languages borrowed heavily from the C language

Using JavaScript in a browser

JavaScript code is included within <script> tags:


<script type="text/javascript"> document.write("<h1>Hello World!</h1>") ; </script> Or just within <script> and </script>

Notes:
The type attribute is to allow you to use other scripting languages (but JavaScript is the default)

Where to put JavaScript

JavaScript can be put in the <head> or in the <body> of an HTML document


JavaScript functions should be defined in the <head> This ensures that the function is loaded before it is needed JavaScript in the <body> will be executed as the page loads

Objects & Functions Event Handling Form Validation

Event Handling
CSS with Java Script

<div style="backgroundcolor:#D94A38;width:170px;height:80px;margin:20px;paddingtop:20px;color:#ffffff;font-weight:bold;font-size:18px;float:left;textalign:center;" onmouseover="this.innerHTML=Non Major Elective'" onmouseout="this.innerHTML='Mouse Over Me'">Offered by University Informatics Centre</div>

Click Event
<!DOCTYPE html> <html> <head> <script> function myfun(id) { id.innerHTML="<b><u><em>Click to draw an underline and make it Italic!</em></u></b>"; } </script> </head> <body> <h1 onclick="myfun(this)">Click to draw an underline and to make it Italic!</h1> </body> </html>

Form Handling
<!DOCTYPE html> <html> <head> <script> function ff() { var x=document.forms["sample"]["sname"].value; if (x==null || x=="") { alert("Student name must be filled out"); return false; } } </script>

<form name="sample" action="uuu.php" onsubmit="return ff()" method="post"> Student name: <input type="text" name="sname"> <input type="submit" value="Submit"> </form>

Q and A

You might also like