SlideShare a Scribd company logo
13-05-2013Rajavel DRajavel D
JavaScript
Summer Internship – 2013
(Indian Institute of Technology Bombay)
JavaScript
 JavaScript is a lightweight scripting language
 Embedded directly into HTML pages
 JavaScript is an interpreted language (means
that scripts execute without preliminary
compilation)
Rajavel D JavaScript IITB-CSE-Internship 2013
What can a JavaScript do?
 Client side data validation
 React to event on html element
 Read and write the html element
 Put dynamic content on html pages
 Creates the client side persistent (cookies, session )
Rajavel D JavaScript IITB-CSE-Internship 2013
Sample JavaScript
<html>
<body>
<p id="demo"></p>
<script type="text/javascript">
document.getElementById("demo").innerHTML=Date();
</script>
</body>
</html>
Rajavel D JavaScript IITB-CSE-Internship 2013
JavaScript in <head>
<html> <head>
<script type="text/javascript">
function displayDate()
{ document.getElementById("demo").innerHTML=Date();
}
</script>
</head>
<body> <p id="demo"></p>
<button type="button" onclick="displayDate()">Display
Date</button>
</body> </html>
Rajavel D JavaScript IITB-CSE-Internship 2013
Using an External JavaScript
<head>
<script type="text/javascript" src=“myjavascript.js"></script>
</head>
 JavaScript Statements
 The semicolon is optional
 Using semicolons makes it possible to write multiple statements
on one line.
 Each statement is executed by the browser in the sequence
they are written
Rajavel D JavaScript IITB-CSE-Internship 2013
Comments and Popup Boxes
 JavaScript Comments
 Single line comments start with //.
 Multi line comments start with /* and end with */.
 JavaScript Popup Boxes
 alert("I am an alert box!");
 var r=confirm("Press a button");
 r = true | false
 var name=prompt("Please enter your name","");
Rajavel D JavaScript IITB-CSE-Internship 2013
JavaScript Events
 onLoad and onUnload
 onFocus, onBlur and onChange
 OnSubmit
 onMouseOver, onmousedown, onmouseout
 Onerror
 Onkeydown, onkeyup
 onselect
Rajavel D JavaScript IITB-CSE-Internship 2013
Required Fields Validation
function validateForm()
{
var x=document.getElementById("txt").value
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
Rajavel D JavaScript IITB-CSE-Internship 2013
E-mail Validation
function validateForm()
{
var x=document.forms["myForm"]["email"].value
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
}
}
Rajavel D JavaScript IITB-CSE-Internship 2013
JavaScript Advanced
Timing
setTimeout("MsgAfter3sec()",3000);
clearTimeout();
Object
<script type="text/javascript">
personObj={firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"}
document.write(personObj.firstname + " is " + personObj.age + " years old.");
</script>
Rajavel D JavaScript IITB-CSE-Internship 2013
JavaScript Cookies
 A cookie is a variable that is stored on the
visitor's computer
 With JavaScript, you can both create and
retrieve cookie values.
Rajavel D JavaScript IITB-CSE-Internship 2013
Create and Store a Cookie
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : ";
expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
Rajavel D JavaScript IITB-CSE-Internship 2013
Get a Cookie
function getCookie(c_name)
{
var i,x,y,Mycookies=document.cookie.split(";");
for (i=0;i<Mycookies.length;i++)
{
x=Mycookies[i].substr(0,Mycookies[i].indexOf("="));
y=Mycookies[i].substr(Mycookies[i].indexOf("=")+1);
if (x==c_name)
return unescape(y);
} }
Rajavel D JavaScript IITB-CSE-Internship 2013
Check Cookie
function checkCookie()
{
var username=getCookie("username");
if (username!=null && username!="")
alert("Welcome again " + username);
else
{ username=prompt("Please enter your name:","");
if (username!=null && username!="")
setCookie("username",username,365);
}
}
Rajavel D JavaScript IITB-CSE-Internship 2013
Document Object
 document.anchors/forms/images.length
 document.anchors[0].innerHTML
 document.title, document.URL
 document.getElementById("myHeader").innerHTML
 document.open("text/html","replace");doc.write(“<html>...</html>”);
 document.getElementsByTagName("input");
 document.getElementById("frm1").reset();
 Event Object
 onmousedown="whichButton(event)", //event.button==2 --> right
 onkeyup="whichButton(event)"//event.keyCode --> ascii
Rajavel D JavaScript IITB-CSE-Internship 2013
CSS on JavaScript
 Changing the dynamic style
 Examples :
 doc.getElementById(“mydiv”).style.Background=“#fdf”
 doc.getElementById("mydiv").style.fontSize= “20px";
 document.getElementById("mydiv").style.color= "#fff";
 doc.getElementById(“div").style.display="block/none";
Rajavel D JavaScript IITB-CSE-Internship 2013
Rajavel D JavaScript IITB-CSE-Internship 2013
Any Doubts ???
References
 www.w3schools.com/js/
 www.tutorialspoint.com/javascript/
Rajavel D JavaScript IITB-CSE-Internship 2013
Ad

More Related Content

What's hot (20)

javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Javascript
JavascriptJavascript
Javascript
Sun Technlogies
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch API
Xcat Liu
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Introduction to JavaScript (1).ppt
Introduction to JavaScript (1).pptIntroduction to JavaScript (1).ppt
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
Ana Cidre
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
Jalpesh Vasa
 
Css
CssCss
Css
Hemant Saini
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
Amit Baghel
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
Mats Bryntse
 
CSS
CSSCSS
CSS
Vladimir Zhidal
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
Yuriy Bezgachnyuk
 
Javascript Basic
Javascript BasicJavascript Basic
Javascript Basic
Kang-min Liu
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
Shlomi Komemi
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
sentayehu
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
Laurence Svekis ✔
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
JavaScript Fetch API
JavaScript Fetch APIJavaScript Fetch API
JavaScript Fetch API
Xcat Liu
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
Introduction to JavaScript (1).ppt
Introduction to JavaScript (1).pptIntroduction to JavaScript (1).ppt
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
Ana Cidre
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 

Viewers also liked (6)

Jsp
JspJsp
Jsp
Rajavel Dhandabani
 
Audio video class room
Audio video class roomAudio video class room
Audio video class room
Rajavel Dhandabani
 
Javascript
JavascriptJavascript
Javascript
Rajavel Dhandabani
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
Rajavel Dhandabani
 
Java
JavaJava
Java
Rajavel Dhandabani
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
LinkedIn
 
Ad

Similar to Javascript (20)

Java script
Java scriptJava script
Java script
Soham Sengupta
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
pkaviya
 
Webdesing lab part-b__java_script_
Webdesing lab part-b__java_script_Webdesing lab part-b__java_script_
Webdesing lab part-b__java_script_
Shivanand Algundi
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III Javascript
Arti Parab Academics
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Unit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatioUnit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
Java script
Java scriptJava script
Java script
Fajar Baskoro
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
Hoat Le
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
Nerd Tzanetopoulos
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
Shawn Calvert
 
JavaScript Web Development
JavaScript Web DevelopmentJavaScript Web Development
JavaScript Web Development
vito jeng
 
Advance java
Advance javaAdvance java
Advance java
Vivek Kumar Sinha
 
JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
Bhavya Siddappa
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordova
Ayman Mahfouz
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
단일 페이지 인터페이스 웹/앱 개발
단일 페이지 인터페이스 웹/앱 개발단일 페이지 인터페이스 웹/앱 개발
단일 페이지 인터페이스 웹/앱 개발
동수 장
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
Java script Learn Easy
Java script Learn Easy Java script Learn Easy
Java script Learn Easy
prince Loffar
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
Ajay Khatri
 
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and ScriptingIT2255 Web Essentials - Unit III Client-Side Processing and Scripting
IT2255 Web Essentials - Unit III Client-Side Processing and Scripting
pkaviya
 
Webdesing lab part-b__java_script_
Webdesing lab part-b__java_script_Webdesing lab part-b__java_script_
Webdesing lab part-b__java_script_
Shivanand Algundi
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III Javascript
Arti Parab Academics
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
masahiroookubo
 
Unit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatioUnit III.pptx IT3401 web essentials presentatio
Unit III.pptx IT3401 web essentials presentatio
lakshitakumar291
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
Hoat Le
 
Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
Nerd Tzanetopoulos
 
JavaScript Web Development
JavaScript Web DevelopmentJavaScript Web Development
JavaScript Web Development
vito jeng
 
JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
Bhavya Siddappa
 
Gdg dev fest hybrid apps your own mini-cordova
Gdg dev fest hybrid apps  your own mini-cordovaGdg dev fest hybrid apps  your own mini-cordova
Gdg dev fest hybrid apps your own mini-cordova
Ayman Mahfouz
 
단일 페이지 인터페이스 웹/앱 개발
단일 페이지 인터페이스 웹/앱 개발단일 페이지 인터페이스 웹/앱 개발
단일 페이지 인터페이스 웹/앱 개발
동수 장
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
Java script Learn Easy
Java script Learn Easy Java script Learn Easy
Java script Learn Easy
prince Loffar
 
Ad

Recently uploaded (20)

Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 

Javascript

  • 1. 13-05-2013Rajavel DRajavel D JavaScript Summer Internship – 2013 (Indian Institute of Technology Bombay)
  • 2. JavaScript  JavaScript is a lightweight scripting language  Embedded directly into HTML pages  JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Rajavel D JavaScript IITB-CSE-Internship 2013
  • 3. What can a JavaScript do?  Client side data validation  React to event on html element  Read and write the html element  Put dynamic content on html pages  Creates the client side persistent (cookies, session ) Rajavel D JavaScript IITB-CSE-Internship 2013
  • 4. Sample JavaScript <html> <body> <p id="demo"></p> <script type="text/javascript"> document.getElementById("demo").innerHTML=Date(); </script> </body> </html> Rajavel D JavaScript IITB-CSE-Internship 2013
  • 5. JavaScript in <head> <html> <head> <script type="text/javascript"> function displayDate() { document.getElementById("demo").innerHTML=Date(); } </script> </head> <body> <p id="demo"></p> <button type="button" onclick="displayDate()">Display Date</button> </body> </html> Rajavel D JavaScript IITB-CSE-Internship 2013
  • 6. Using an External JavaScript <head> <script type="text/javascript" src=“myjavascript.js"></script> </head>  JavaScript Statements  The semicolon is optional  Using semicolons makes it possible to write multiple statements on one line.  Each statement is executed by the browser in the sequence they are written Rajavel D JavaScript IITB-CSE-Internship 2013
  • 7. Comments and Popup Boxes  JavaScript Comments  Single line comments start with //.  Multi line comments start with /* and end with */.  JavaScript Popup Boxes  alert("I am an alert box!");  var r=confirm("Press a button");  r = true | false  var name=prompt("Please enter your name",""); Rajavel D JavaScript IITB-CSE-Internship 2013
  • 8. JavaScript Events  onLoad and onUnload  onFocus, onBlur and onChange  OnSubmit  onMouseOver, onmousedown, onmouseout  Onerror  Onkeydown, onkeyup  onselect Rajavel D JavaScript IITB-CSE-Internship 2013
  • 9. Required Fields Validation function validateForm() { var x=document.getElementById("txt").value if (x==null || x=="") { alert("First name must be filled out"); return false; } } Rajavel D JavaScript IITB-CSE-Internship 2013
  • 10. E-mail Validation function validateForm() { var x=document.forms["myForm"]["email"].value var atpos=x.indexOf("@"); var dotpos=x.lastIndexOf("."); if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) { alert("Not a valid e-mail address"); return false; } } Rajavel D JavaScript IITB-CSE-Internship 2013
  • 12. JavaScript Cookies  A cookie is a variable that is stored on the visitor's computer  With JavaScript, you can both create and retrieve cookie values. Rajavel D JavaScript IITB-CSE-Internship 2013
  • 13. Create and Store a Cookie function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } Rajavel D JavaScript IITB-CSE-Internship 2013
  • 14. Get a Cookie function getCookie(c_name) { var i,x,y,Mycookies=document.cookie.split(";"); for (i=0;i<Mycookies.length;i++) { x=Mycookies[i].substr(0,Mycookies[i].indexOf("=")); y=Mycookies[i].substr(Mycookies[i].indexOf("=")+1); if (x==c_name) return unescape(y); } } Rajavel D JavaScript IITB-CSE-Internship 2013
  • 15. Check Cookie function checkCookie() { var username=getCookie("username"); if (username!=null && username!="") alert("Welcome again " + username); else { username=prompt("Please enter your name:",""); if (username!=null && username!="") setCookie("username",username,365); } } Rajavel D JavaScript IITB-CSE-Internship 2013
  • 16. Document Object  document.anchors/forms/images.length  document.anchors[0].innerHTML  document.title, document.URL  document.getElementById("myHeader").innerHTML  document.open("text/html","replace");doc.write(“<html>...</html>”);  document.getElementsByTagName("input");  document.getElementById("frm1").reset();  Event Object  onmousedown="whichButton(event)", //event.button==2 --> right  onkeyup="whichButton(event)"//event.keyCode --> ascii Rajavel D JavaScript IITB-CSE-Internship 2013
  • 17. CSS on JavaScript  Changing the dynamic style  Examples :  doc.getElementById(“mydiv”).style.Background=“#fdf”  doc.getElementById("mydiv").style.fontSize= “20px";  document.getElementById("mydiv").style.color= "#fff";  doc.getElementById(“div").style.display="block/none"; Rajavel D JavaScript IITB-CSE-Internship 2013
  • 18. Rajavel D JavaScript IITB-CSE-Internship 2013 Any Doubts ???