SlideShare a Scribd company logo
JavaScript Basic programs
by
Satish Shende
satish.sixteen@gmail.com
Message Box
alert
window.alert("Welcome to my site!")
confirm
window.confirm("Are you sure you want to quit?")
prompt
window.prompt("please enter user name")
<html>
<head>
<title>
</title>
</head>
<body>
<script>
window.alert("Welcome to my site!")
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<<html><head>
<script>
var x=confirm("Are you sure you want to quit?")
if (!x)
window.location="http://www.vdfindia.org/"
</script>
</head>
<body>
Welcome to my website!.
</body></html>
</body>
</html>
Variable
Variables and Conditions
<script>
var x=window.confirm("Are you sure you want
to quit")
if (x)
window.alert("Thank you.")
else
window.alert("Good choice.")
</script>
<html><head>
<script>
var x=confirm("Are you sure you want to quit?")
if (!x)
window.location="http://www.yahoo.com"
</script>
</head>
<body>
Welcome to my website!.
</body></html>
Function
<html><head><title></title></head>
<body>
<script>
function test()
{
document.write("Hello can you see me?")
}
</script>
</body></html>
functions are not executed by themselves until
you call upon them.
<html><head><title></title></head>
<body>
<script>
function test()
{
document.write("Hello can you see me?")
}
test()
</script>
</body></html>
Call function
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript</h1>
<p id="demo">JavaScript can change the style of an HTML element.</p>
<script>
function myFunction() {
document.getElementById("demo").style.fontSize = "25px";
document.getElementById("demo").style.color = "red";
document.getElementById("demo").style.backgroundColor = "yellow";
}
</script>
<button type="button" onclick="myFunction()">Click Me!</button>
</body>
</html>
Event handler
What are event handlers?
execute JavaScript when
something happens, such as
• click or move your mouse over
a link,
• submit a form etc.
<html><head><title></title></head>
<body>
<script>
function ss()
{
alert("Thank you! For click")
}
</script>
<form>
<input type="button" value="Click here" onclick="ss()">
</form>
</body></html>
</head><body>
< script Language="JavaScript">
function checkLogin(x)
{
if ((x.id.value != "Sam")||(x.pass.value !="Sam123"))
{
alert("Invalid Login");
return false;
}
else
location="main.htm"
}
</script>
<form>
<p>UserID:<input type="text" name="id"></p>
<p>Password:<input type="password" name="pass"></p>
<p><input type="button" value="Login"
onClick="checkLogin(this.form)"></p>
</form>
</body></html>
<html><head><title>show
date</title></head>
<body>
<script language="javascript">
var x= new date();
document.write (x);
</script>
</body></html>
Date
<html><head><title>show
date</title></head>
<body>
<script language="javascript">
var bantime= new date()
var ss=bantime.gethours()
if (ss<=20)
document.write("<img src='http://www.world-trail.com/wp-
content/uploads/2015/08/world_trail_logo.png'>")
else
document.write("<img
src='https://static01.nyt.com/images/2016/05/03/world/what-in-
the-world/witw-promo/witw-promo-thumblarge.jpg'>")
</script>
</body></html>
Javascript basic programs
Window To open a window, simply use the method
"window.open()":
<html><head><title>new
window</title></head>
<body>
<form>
<input type="button" value="click
here to see"
onclick="window.open('https://w
ww.youtube.com/?gl=in')">
</form>
</body></html>
<html><head><title></title></head>
<body>
<form>
<input type="button" value="Visit LinkedIn"
onClick="aa=window.open('http://www.linkedin.com/','','width=200,height=200')">
<input type="button" value="Visit Google"
onClick="aa=window.open('https://www.google.com/','','width=200,height=200')">
<input type="button" value="Know about Weather"
onClick="aa=window.open('https://www.accuweather.com/en/in/satara/189287/w
eather-forecast/189287','','width=200,height=200')">
<input type="button" value="Visit YouTube"
onClick="aa=window.open('https://www.youtube.com/?gl=IN','','width=200,height=
200')">
</form>
</body></html>
<html><head><title>new
window</title></head>
<body>
<form>
<input type="button" value="click here to see"
onclick="window.open('page2.htm','win1','widt
h=200,height=200,menubar')">
</form>
</body></html>
script to control the size of the window
JavaScript with HTML + CSS
Show Date
(using HTML + Javascript)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Show date</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"> </script>
</head>
<body onload = "showDate()">
<button onmouseout = "clearDate()" onmouseover="showDate()">Show
Date
</button>
<h1 id="time"></h1>
</html>
HTML
function showDate(){
var time = document.getElementById("time");
time.innerHTML = Date();
}
function clearDate(){
var time = document.getElementById("time");
time.innerHTML = '';
}
Javascript
Increase font size
(using HTML + Javascript)
<div class="text_area" id="demo_4">
<p>Happy Birthday</p>
<button onclick=myfunctionThree();>Press
here</button>
</div>
function myfunctionThree()
{
document.getElementById
("demo_4").style.fontSize
= "30px";
}
HTML
JavaScript
Display an image
(using HTML + CSS + Javascript)
<link rel="stylesheet" href="style.css">
<button onclick=myfunctionFive();>Now
Click</button>
<a id="demo_6">
<img class="one"
src="https://images.pexels.com/photos/4
59225/pexels-photo-
459225.jpeg?auto=compress&cs=tinysrgb
&h=350">
</a>
HTML
#demo_6{
display:none;
}
.one {
border: 1px solid blue;
padding: 15px;
margin: 5px }
css
function myfunctionFive()
{
document.getElementById
("demo_6").style.display = "block";
}
javascript
img {
border-radius: 8px;
}
css
img {
border-radius: 50%;
}
img:hover {
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
}

More Related Content

PPTX
Java script cookies
PPT
JavaScript Training
ODP
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
PDF
Black-Scholes Calculator on Web
DOCX
Javascript
KEY
The go-start webframework (GTUG Vienna 27.03.2012)
TXT
The project gutenberg e book, fairy tales from brazil, by elsie spicer
PPTX
jQuery Mobile - Desenvolvimento para dispositivos móveis
Java script cookies
JavaScript Training
Nagios Conference 2014 - Troy Lea - JavaScript and jQuery - Nagios XI Tips, T...
Black-Scholes Calculator on Web
Javascript
The go-start webframework (GTUG Vienna 27.03.2012)
The project gutenberg e book, fairy tales from brazil, by elsie spicer
jQuery Mobile - Desenvolvimento para dispositivos móveis

What's hot (20)

PDF
Assignment4
 
PDF
Casl. isomorphic permission management.pptx
TXT
Convidar para page !!
PDF
Our application got popular and now it breaks
KEY
Client-side Transformations
PDF
The Thinking behind BEM
PDF
22 j query1
PPT
JavaScript
PDF
The Future of CSS with Web Components
DOCX
Font size
PPTX
J query
PDF
JAVA SCRIPT
PDF
Merb jQuery
PDF
Html server control - ASP. NET with c#
PDF
jQuery Presentation to Rails Developers
TXT
Index
PPTX
Java script
TXT
Fcr 2
PDF
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
PPT
Desenvolvimento web com jQuery Mobile
Assignment4
 
Casl. isomorphic permission management.pptx
Convidar para page !!
Our application got popular and now it breaks
Client-side Transformations
The Thinking behind BEM
22 j query1
JavaScript
The Future of CSS with Web Components
Font size
J query
JAVA SCRIPT
Merb jQuery
Html server control - ASP. NET with c#
jQuery Presentation to Rails Developers
Index
Java script
Fcr 2
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Desenvolvimento web com jQuery Mobile
Ad

Similar to Javascript basic programs (20)

PPTX
Java script page redirection
PDF
Java script programms
PPTX
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
PPTX
JavaServer Pages
PPTX
Java script events
PDF
HTML5 New and Improved
TXT
smoke1272528461
PPTX
PPTX
JavaScript Operators
PPTX
course js day 3
PDF
Jquery for post a form
PDF
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
PDF
HTML5 - The 2012 of the Web
PPTX
Training in Asp.net mvc3 platform-apextgi,noida
PPTX
計算機概論20161212
PPTX
Java script form validation
TXT
Ip lab
PDF
20190118_NetadashiMeetup#8_React2019
PPTX
Java script errors &amp; exceptions handling
Java script page redirection
Java script programms
Internet and Web Technology (CLASS-8) [jQuery and JSON] | NIC/NIELIT Web Tech...
JavaServer Pages
Java script events
HTML5 New and Improved
smoke1272528461
JavaScript Operators
course js day 3
Jquery for post a form
Training in Asp.net mvc3 platform-apextgi,noidaAspnetmvc3 j query
HTML5 - The 2012 of the Web
Training in Asp.net mvc3 platform-apextgi,noida
計算機概論20161212
Java script form validation
Ip lab
20190118_NetadashiMeetup#8_React2019
Java script errors &amp; exceptions handling
Ad

More from Digital Shende (20)

PDF
Phoenix Cancer Clinic Satara Trust and Care for Patients.pdf
PPTX
The Rise of UPI & Cashless Transactions: How Mobile Payment Apps Are Transfor...
PDF
Shahi Foods – Where Tradition Meets Taste..
PPTX
Google for Nonprofits eligible organizations
PDF
Google Notebook LM How Specialized Knowledge Integration is Revolutionizing L...
PPTX
Digital Marketing Resume for Fresher.pptx
PDF
Mastering Digital Marketing: Unlocking Success with The POEM Frameworks
PPTX
Digital Marketing for Women's Self-Help group
PPTX
How to Set Up a Google Ads Account Without a Campaign.pptx
PDF
Introduction to google certified educator level 1
PDF
Build your own google site explation in marathi
PPTX
Digital marketing overview 2021
PDF
Digital Shende (Satish Shende) Visual Profile
PDF
Satish Shende, Satara Profile
PDF
Highlights from the 7th Google for India event
PPTX
Elements – App Screenshots
PPTX
Aarogya setu application
PPTX
Corona kavach app Beta Version Screenshots
PPTX
Content Creation Tools
PPTX
Entrepreneurial Opportunities in Digital Marketing
Phoenix Cancer Clinic Satara Trust and Care for Patients.pdf
The Rise of UPI & Cashless Transactions: How Mobile Payment Apps Are Transfor...
Shahi Foods – Where Tradition Meets Taste..
Google for Nonprofits eligible organizations
Google Notebook LM How Specialized Knowledge Integration is Revolutionizing L...
Digital Marketing Resume for Fresher.pptx
Mastering Digital Marketing: Unlocking Success with The POEM Frameworks
Digital Marketing for Women's Self-Help group
How to Set Up a Google Ads Account Without a Campaign.pptx
Introduction to google certified educator level 1
Build your own google site explation in marathi
Digital marketing overview 2021
Digital Shende (Satish Shende) Visual Profile
Satish Shende, Satara Profile
Highlights from the 7th Google for India event
Elements – App Screenshots
Aarogya setu application
Corona kavach app Beta Version Screenshots
Content Creation Tools
Entrepreneurial Opportunities in Digital Marketing

Recently uploaded (20)

PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Institutional Correction lecture only . . .
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Types and Its function , kingdom of life
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Pre independence Education in Inndia.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Classroom Observation Tools for Teachers
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
TR - Agricultural Crops Production NC III.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Institutional Correction lecture only . . .
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Types and Its function , kingdom of life
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pre independence Education in Inndia.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
01-Introduction-to-Information-Management.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Renaissance Architecture: A Journey from Faith to Humanism
Classroom Observation Tools for Teachers
STATICS OF THE RIGID BODIES Hibbelers.pdf
Supply Chain Operations Speaking Notes -ICLT Program
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra

Javascript basic programs