SlideShare a Scribd company logo
1 of 31
Download to read offline
SOURAV NEWATIA(NIT KURUKSHETRA)
​ ​JAVASCRIPT
​SOURAV NEWATIA
​21th DECEMBER, 2016
0
SOURAV NEWATIA(NIT KURUKSHETRA)
​INTRODUCTION
JavaScript is a lightweight, interpreted programming language. It is designed for creating
network-centric applications. It is complimentary to and integrated with Java. JavaScript is very
easy to implement because it is integrated with HTML. It is open and cross-platform.
JavaScript is incredibly versatile. You can start small, with carousels, image galleries, fluctuating
layouts, and responses to button clicks. With more experience you'll be able to create games,
animated 2D and 3D graphics, comprehensive database-driven apps, and much more!
Important Points:
(1) ​ ​JavaScript is the programming language of HTML and the Web.
(2) JavaScript is easy to learn.
(3) JavaScript Works together with HTML and CSS to create attractive & interactive Websites.
1
SOURAV NEWATIA(NIT KURUKSHETRA)
Advantages of JavaScript:
The merits of using JavaScript are −
● Less server interaction − You can validate user input before sending the page off to the
server. This saves server traffic, which means less load on your server.
● Immediate feedback to the visitors − They don't have to wait for a page reload to see if they
have forgotten to enter something.
● Increased interactivity − You can create interfaces that react when the user hovers over them
with a mouse or activates them via the keyboard.
● Richer interfaces − You can use JavaScript to include such items as drag-and-drop components
and sliders to give a Rich Interface to your site visitors.
JavaScript Development Tools:-
One of major strengths of JavaScript is that it does not require expensive development tools. You can
start with a simple text editor such as Notepad. Since it is an interpreted language inside the context of
a web browser, you don't even need to buy a compiler.
To make our life simpler, various vendors have come up with very nice JavaScript editing tools. Some of
them are listed here −
● Microsoft FrontPage − Microsoft has developed a popular HTML editor called FrontPage.
FrontPage also provides web developers with a number of JavaScript tools to assist in the
creation of interactive websites.
● Macromedia Dreamweaver MX − Macromedia Dreamweaver MX is a very popular HTML and
JavaScript editor in the professional web development crowd. It provides several handy prebuilt
JavaScript components, integrates well with databases, and conforms to new standards such as
XHTML and XML.
2
SOURAV NEWATIA(NIT KURUKSHETRA)
Using JavaScript:-
When used in a web page , the JavaScript scripting language works inside the ​web Browser
Here are a Few examples of what you can do with JavaScript:
- ​ Display ​information based on the time of day
- ​Detect​ the visitor’s browser
- ​Validate​ forms data
- ​Create​ cookies
- ​Change​ page contents dynamically
- And much ​more​!!!!!
3
SOURAV NEWATIA(NIT KURUKSHETRA)
Others Uses Of JavaScript:-
As Previously mentioned, JavaScript was designed to run as a scripting language, Inside the Web browser.
But as JavaScript has become popular , you can find it in other ​applications​ (e.g.: Adobe Acrobat) and even
server-side​ (e.g.: Node.js) products.
Note:​-
It is Recommended that you gain Basic knowledge of ​HTML​ and ​CSS​.
4
SOURAV NEWATIA(NIT KURUKSHETRA)
​CREATING YOUR FIRST JAVASCRIPT:-
JavaScript lives inside the HTML document.Below is a simple HTML document, with​ <head>​ and
<body>​ tags , in which we will write our javascript code.
In HTML, JavaScript code must be inserted between ​<script>​ and ​</script>​ tags :
5
SOURAV NEWATIA(NIT KURUKSHETRA)
JavaScript can be placed in the HTML page’s ​<body>​ and ​<head> ​sections. In the example below ,
we placed it within the ​<body>​ tag.
Let’s use JavaScript to print ​“Hello World”​ to the browser.
6
SOURAV NEWATIA(NIT KURUKSHETRA)
The ​document.write()​ function writes a string into our HTML document.This function can be used
to write text,HTML,or both.
The Above code displays the following results:-
Formatting Text :-
Just like in HTML, we can use HTML tags to format text in JavaScript.For example, we can output
the text as a heading.
OUTPUT :- Hello World
7
SOURAV NEWATIA(NIT KURUKSHETRA)
​ ADDING JAVASCRIPT TO A WEB PAGE:-
javaScript in <head> :-
You can place any number of scripts in an HTML document.Typically , the script tag is placed in the
head of the HTML document:
JavaScript in <body> :-
You can place Alternatively , Include the JavaScript in the <body> tag.
8
SOURAV NEWATIA(NIT KURUKSHETRA)
The <Script> Tag :-
The​ ​<script>​ ​tag can take two attributes, ​language​ and ​type​ , which specify the script’s type:
In the example below , we created an alert box inside the script tag , using the​ alert() ​function.
9
SOURAV NEWATIA(NIT KURUKSHETRA)
​ JavaScript Datatypes
One of the most fundamental characteristics of a programming language is the set of data types it
supports. These are the type of values that can be represented and manipulated in a programming
language.
JavaScript allows you to work with three primitive data types −
● Numbers,​ eg. 123, 120.50 etc.
● Strings​ of text e.g. "This text string" etc.
● Boolean​ e.g. true or false.
JavaScript also defines two trivial data types, ​null and ​undefined, each of which defines only a
single value. In addition to these primitive data types, JavaScript supports a composite data type
known as ​object​.
​JavaScript Variables
Like many other programming languages, JavaScript has variables. Variables can be thought of as
named containers. You can place data into these containers and then refer to the data simply by
naming the container.
Before you use a variable in a JavaScript program, you must declare it. Variables are declared with
the var keyword.
10
SOURAV NEWATIA(NIT KURUKSHETRA)
​JavaScript Variable Scope:-
The scope of a variable is the region of your program in which it is defined. JavaScript variables
have only two scopes.
● Global Variables − A global variable has global scope which means it can be defined anywhere
in your JavaScript code.
● Local Variables − A local variable will be visible only within a function where it is defined.
Function parameters are always local to that function.
Within the body of a function, a local variable takes precedence over a global variable with the
same name. If you declare a local variable or function parameter with the same name as a global
variable, you effectively hidethe global variable.
11
SOURAV NEWATIA(NIT KURUKSHETRA)
JavaScript - Functions
A function is a group of reusable code which can be called anywhere in your program. This
eliminates the need of writing the same code again and again. It helps programmers in writing
modular codes. Functions allow a programmer to divide a big program into a number of small and
manageable functions.
Like any other advanced programming language, JavaScript also supports all the features
necessary to write modular code using functions. You must have seen functions like alert() and
write() in the earlier chapters. We were using these functions again and again, but they had been
written in core JavaScript only once.
Before we use a function, we need to define it. The most common way to define a function in
JavaScript is by using the function keyword, followed by a unique function name, a list of
parameters (that might be empty), and a statement block surrounded by curly braces.
12
SOURAV NEWATIA(NIT KURUKSHETRA)
Calling a Function:
To invoke a function somewhere later in the script, you would simply need to write the
name of that function as shown in the following code.
Output:-
13
SOURAV NEWATIA(NIT KURUKSHETRA)
Function Parameters
Till now, we have seen functions without parameters. But there is a facility to pass different
parameters while calling a function. These passed parameters can be captured inside the
function and any manipulation can be done over those parameters. A function can take
multiple parameters separated by comma.
Example
Try the following example. We have modified our ​sayHello function here. Now it takes two
parameters.
Output:-
14
SOURAV NEWATIA(NIT KURUKSHETRA)
JavaScript - Events
JavaScript's interaction with HTML is handled through events that occur when the user or the
browser manipulates a page.When the page loads, it is called an event. When the user clicks a
button, that click too is an event. Other examples include events like pressing any key, closing a
window, resizing a window, etc.
Developers can use these events to execute JavaScript coded responses, which cause buttons to
close windows, messages to be displayed to users, data to be validated, and virtually any other type
of response imaginable.
onclick Event Type
This is the most frequently used event type which occurs when a user clicks the left button
of his mouse. You can put your validation, warning etc., against this event type.
onsubmit Event Type:
15
SOURAV NEWATIA(NIT KURUKSHETRA)
onsubmit is an event that occurs when you try to submit a form. You can put your form validation
against this event type.
Example
The following example shows how to use onsubmit. Here we are calling a ​validate() function
before submitting a form data to the webserver. If ​validate() function returns true, the form will
be submitted, otherwise it will not submit the data.
16
SOURAV NEWATIA(NIT KURUKSHETRA)
​ ​HTML 5 Standard Events
17
SOURAV NEWATIA(NIT KURUKSHETRA)
18
SOURAV NEWATIA(NIT KURUKSHETRA)
19
SOURAV NEWATIA(NIT KURUKSHETRA)
JavaScript - Dialog Boxes
JavaScript supports three important types of dialog boxes. These dialog boxes can be used to raise
and alert, or to get confirmation on any input or to have a kind of input from the users.
Alert Dialog Box
An alert dialog box is mostly used to give a warning message to the users. For example, if one input
field requires to enter some text but the user does not provide any input, then as a part of
validation, you can use an alert box to give a warning message.
Nonetheless, an alert box can still be used for friendlier messages. Alert box gives only one button
"OK" to select and proceed.
20
SOURAV NEWATIA(NIT KURUKSHETRA)
OUTPUT:-
Confirmation Dialog Box
A confirmation dialog box is mostly used to take user's consent on any option. It displays a dialog
box with two buttons: ​Cancel​.
If the user clicks on the OK button, the window method ​confirm() will return true. If the user
clicks on the Cancel button, then ​confirm() returns false. You can use a confirmation dialog box as
follows.
21
SOURAV NEWATIA(NIT KURUKSHETRA)
Prompt Dialog Box
The prompt dialog box is very useful when you want to pop-up a text box to get user input. Thus, it
enables you to interact with the user. The user needs to fill in the field and then click OK.
This dialog box is displayed using a method called ​prompt() which takes two parameters: (i) a
label which you want to display in the text box and (ii) a default string to display in the text box.
This dialog box has two buttons: ​OK and ​Cancel​. If the user clicks the OK button, the window
method ​prompt() will return the entered value from the text box. If the user clicks the Cancel
button, the window method ​prompt()​ returns ​null​.
OUTPUT:
22
SOURAV NEWATIA(NIT KURUKSHETRA)
​JavaScript - Debugging
Every now and then, developers commit mistakes while coding. A mistake in a program or a script is
referred to as a ​bug​.
The process of finding and fixing bugs is called ​debugging and is a normal part of the development
process. This section covers tools and techniques that can help you with debugging tasks..
Error Messages in IE
The most basic way to track down errors is by turning on error information in your browser. By
default, Internet Explorer shows an error icon in the status bar when an error occurs on the page.
Double-clicking this icon takes you to a dialog box showing information about the specific error that
occurred.
Since this icon is easy to overlook, Internet Explorer gives you the option to automatically show the
Error dialog box whenever an error occurs.
To enable this option, select ​Tools → Internet Options → Advanced tab. and then finally check
the ​"Display a Notification About Every Script Error"​ box option as shown below −
23
SOURAV NEWATIA(NIT KURUKSHETRA)
Error Messages in Firefox or Mozilla
Other browsers like Firefox, Netscape, and Mozilla send error messages to a special window called the
JavaScript Console or ​Error Consol​. To view the console, select ​Tools → Error Consol or Web
Development​.
24
SOURAV NEWATIA(NIT KURUKSHETRA)
Disable JavaScript :-
IN GOOGLE CHROME
1. Select the “Menu” button located at the upper-right corner of the screen, then
select “Settings“, or type ​“chrome://settings/content“ in the address bar, press
“Enter“, then skip to step 3.
2. Scroll down and select the “Show advanced settings…” option.
3. Select the “Content settings…” button.
4. Select “Allow all sites to run JavaScript” to enable JavaScript, select “Do not allow any
site to run JavaScript” to disable it.
25
SOURAV NEWATIA(NIT KURUKSHETRA)
How To Create A Simple Calculator Using HTML And
JavaScript:-
All our calculator will do is basic arithmetic: add, subtract, multiply and divide. Hmm, what about
negative numbers - so we also need to be able to change the sign of a number. What else? Well, we're
going to allow rather big numbers, so it's a good idea to have a button that easily allows us to enter an
exponent (the number times 10something). We need a decimal point. And we need to be able to clear the
display (a CLEAR button), and to clear everything (ALL CLEAR). Let's list out requirements up to now:
• A display area for numbers
• Buttons for 0,1,2, up to 9 •A decimal point button
• A button to change the sign (+/-)
• Clear and all clear (C, AC buttons)
• Function buttons (* / + -)
• An exponent button (EXP)
• A 'calculate' button (The = button)
Let's group our different buttons and boxes into three classes:
• The display area
• The numeric buttons (0 to 9, +/-, .)
• Function buttons together with AC, C, = and EXP
26
SOURAV NEWATIA(NIT KURUKSHETRA)
27
SOURAV NEWATIA(NIT KURUKSHETRA)
28
SOURAV NEWATIA(NIT KURUKSHETRA)
OUTPUT:-
29
SOURAV NEWATIA(NIT KURUKSHETRA)
References:-
(1) http://www.webestools.com/scripts_tutorials-code-sourc
e-8-javascript-calculator-buttons-calculator-keyboard-sup
port-operations-modulo.html
(2) https://en.wikipedia.org/wiki/JavaScript
(3) https://www.tutorialspoint.com/javascript/
(4) http://www.w3schools.com/js/
(5) https://www.sololearn.com/Course/JavaScript/
30

More Related Content

What's hot

JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereLaurence Svekis ✔
 
4007655 introduction-to-javascript
4007655 introduction-to-javascript4007655 introduction-to-javascript
4007655 introduction-to-javascriptVikash Chandra
 
1. java script language fundamentals
1. java script language fundamentals1. java script language fundamentals
1. java script language fundamentalsRajiv Gupta
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascriptambuj pathak
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214Haim Michael
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java scriptDivyaKS12
 
JavaScript Roadmap III - ECMAScript
JavaScript Roadmap III - ECMAScriptJavaScript Roadmap III - ECMAScript
JavaScript Roadmap III - ECMAScriptAswin Barath
 
Java Script An Introduction By HWA
Java Script An Introduction By HWAJava Script An Introduction By HWA
Java Script An Introduction By HWAEmma Wood
 
Java script
Java scriptJava script
Java scriptITz_1
 
Java script Session No 1
Java script Session No 1Java script Session No 1
Java script Session No 1Saif Ullah Dar
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptLaurence Svekis ✔
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java scriptnanjil1984
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Haim Michael
 

What's hot (20)

Javascript
JavascriptJavascript
Javascript
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
 
4007655 introduction-to-javascript
4007655 introduction-to-javascript4007655 introduction-to-javascript
4007655 introduction-to-javascript
 
Javascript by geetanjali
Javascript by geetanjaliJavascript by geetanjali
Javascript by geetanjali
 
1. java script language fundamentals
1. java script language fundamentals1. java script language fundamentals
1. java script language fundamentals
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
JavaScript Jump Start 20220214
JavaScript Jump Start 20220214JavaScript Jump Start 20220214
JavaScript Jump Start 20220214
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
JavaScript Roadmap III - ECMAScript
JavaScript Roadmap III - ECMAScriptJavaScript Roadmap III - ECMAScript
JavaScript Roadmap III - ECMAScript
 
Java Script An Introduction By HWA
Java Script An Introduction By HWAJava Script An Introduction By HWA
Java Script An Introduction By HWA
 
Java Script
Java ScriptJava Script
Java Script
 
Java script
Java scriptJava script
Java script
 
Java script Session No 1
Java script Session No 1Java script Session No 1
Java script Session No 1
 
JavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScriptJavaScript guide 2020 Learn JavaScript
JavaScript guide 2020 Learn JavaScript
 
Java script
Java scriptJava script
Java script
 
Introduction to java script
Introduction to java scriptIntroduction to java script
Introduction to java script
 
Java script
Java scriptJava script
Java script
 
Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start) Node.js Crash Course (Jump Start)
Node.js Crash Course (Jump Start)
 
Java script
Java scriptJava script
Java script
 

Viewers also liked

Nabataeans of Petra
Nabataeans of PetraNabataeans of Petra
Nabataeans of PetraThomas Hill
 
Actu transparence SEA Avocats
Actu transparence SEA AvocatsActu transparence SEA Avocats
Actu transparence SEA AvocatsMarket iT
 
Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...
Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...
Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...Market iT
 
C.V MOHANNAD NOW updated (1)
C.V MOHANNAD NOW updated (1)C.V MOHANNAD NOW updated (1)
C.V MOHANNAD NOW updated (1)mohannad khlifat
 
Evolució naixements
Evolució  naixementsEvolució  naixements
Evolució naixements2011Edu
 
Logiciels et applications mobiles de santé dm ou pas dm
Logiciels et applications mobiles de santé dm ou pas dmLogiciels et applications mobiles de santé dm ou pas dm
Logiciels et applications mobiles de santé dm ou pas dmMarket iT
 
Hunger stage 2 citizenship
Hunger stage 2 citizenshipHunger stage 2 citizenship
Hunger stage 2 citizenshipXavier Ong
 
Agentura vs in-house team
Agentura vs in-house teamAgentura vs in-house team
Agentura vs in-house teamJan Randus
 
Performance marketing na sociálních sítích
Performance marketing na sociálních sítíchPerformance marketing na sociálních sítích
Performance marketing na sociálních sítíchJan Randus
 
HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...
HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...
HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...Market iT
 
2016-10-13 JNI - "Le cadre juridique de la santé numérique"
2016-10-13 JNI - "Le cadre juridique de la santé numérique"2016-10-13 JNI - "Le cadre juridique de la santé numérique"
2016-10-13 JNI - "Le cadre juridique de la santé numérique"ASIP Santé
 
Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2
Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2
Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2Nguyễn Sáu
 

Viewers also liked (15)

Nabataeans of Petra
Nabataeans of PetraNabataeans of Petra
Nabataeans of Petra
 
Actu transparence SEA Avocats
Actu transparence SEA AvocatsActu transparence SEA Avocats
Actu transparence SEA Avocats
 
Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...
Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...
Projet de loi de lutte contre la corruption : le Foreign Corrupt Practices Ac...
 
C.V MOHANNAD NOW updated (1)
C.V MOHANNAD NOW updated (1)C.V MOHANNAD NOW updated (1)
C.V MOHANNAD NOW updated (1)
 
Evolució naixements
Evolució  naixementsEvolució  naixements
Evolució naixements
 
crucigrama
crucigramacrucigrama
crucigrama
 
Romero graciela
Romero gracielaRomero graciela
Romero graciela
 
Logiciels et applications mobiles de santé dm ou pas dm
Logiciels et applications mobiles de santé dm ou pas dmLogiciels et applications mobiles de santé dm ou pas dm
Logiciels et applications mobiles de santé dm ou pas dm
 
Hunger stage 2 citizenship
Hunger stage 2 citizenshipHunger stage 2 citizenship
Hunger stage 2 citizenship
 
Agentura vs in-house team
Agentura vs in-house teamAgentura vs in-house team
Agentura vs in-house team
 
Performance marketing na sociálních sítích
Performance marketing na sociálních sítíchPerformance marketing na sociálních sítích
Performance marketing na sociálních sítích
 
HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...
HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...
HAS : Référentiel de bonnes pratiques sur les applications et les objets conn...
 
2016-10-13 JNI - "Le cadre juridique de la santé numérique"
2016-10-13 JNI - "Le cadre juridique de la santé numérique"2016-10-13 JNI - "Le cadre juridique de la santé numérique"
2016-10-13 JNI - "Le cadre juridique de la santé numérique"
 
Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2
Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2
Chiến Thuật Ôn Thi THPT Quốc Gia Môn Ngữ Văn - Chuyên đề Nghị luận xã hội tập 2
 
DNS,SMTP and POP3
DNS,SMTP and POP3DNS,SMTP and POP3
DNS,SMTP and POP3
 

Similar to JavaScript Basics and Applications by Sourv Newatia

Java script Basic
Java script BasicJava script Basic
Java script BasicJaya Kumari
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptxGangesh8
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentationJohnLagman3
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students shafiq sangi
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)SANTOSH RATH
 
WEB MODULE 3.pdf
WEB MODULE 3.pdfWEB MODULE 3.pdf
WEB MODULE 3.pdfDeepika A B
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxrish15r890
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothBhavsingh Maloth
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHBhavsingh Maloth
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academyactanimation
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPTGo4Guru
 
Java Script - A New Look
Java Script - A New LookJava Script - A New Look
Java Script - A New Lookrumsan
 

Similar to JavaScript Basics and Applications by Sourv Newatia (20)

Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Unit 4 Java script.pptx
Unit 4 Java script.pptxUnit 4 Java script.pptx
Unit 4 Java script.pptx
 
8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation8.-Javascript-report powerpoint presentation
8.-Javascript-report powerpoint presentation
 
Basic Java script handouts for students
Basic Java script handouts for students Basic Java script handouts for students
Basic Java script handouts for students
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
 
Java script hello world
Java script hello worldJava script hello world
Java script hello world
 
web designing course bangalore
web designing course bangaloreweb designing course bangalore
web designing course bangalore
 
WEB MODULE 3.pdf
WEB MODULE 3.pdfWEB MODULE 3.pdf
WEB MODULE 3.pdf
 
WEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScriptWEB TECHNOLOGIES JavaScript
WEB TECHNOLOGIES JavaScript
 
JavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptxJavaScript New Tutorial Class XI and XII.pptx
JavaScript New Tutorial Class XI and XII.pptx
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
 
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTHWEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
WEB PROGRAMMING UNIT II BY BHAVSINGH MALOTH
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
Java script by Act Academy
Java script by Act AcademyJava script by Act Academy
Java script by Act Academy
 
Javascript
JavascriptJavascript
Javascript
 
JAVA SCRIPT
JAVA SCRIPTJAVA SCRIPT
JAVA SCRIPT
 
CSC PPT 12.pptx
CSC PPT 12.pptxCSC PPT 12.pptx
CSC PPT 12.pptx
 
Java Script - A New Look
Java Script - A New LookJava Script - A New Look
Java Script - A New Look
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 

JavaScript Basics and Applications by Sourv Newatia

  • 1. SOURAV NEWATIA(NIT KURUKSHETRA) ​ ​JAVASCRIPT ​SOURAV NEWATIA ​21th DECEMBER, 2016 0
  • 2. SOURAV NEWATIA(NIT KURUKSHETRA) ​INTRODUCTION JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform. JavaScript is incredibly versatile. You can start small, with carousels, image galleries, fluctuating layouts, and responses to button clicks. With more experience you'll be able to create games, animated 2D and 3D graphics, comprehensive database-driven apps, and much more! Important Points: (1) ​ ​JavaScript is the programming language of HTML and the Web. (2) JavaScript is easy to learn. (3) JavaScript Works together with HTML and CSS to create attractive & interactive Websites. 1
  • 3. SOURAV NEWATIA(NIT KURUKSHETRA) Advantages of JavaScript: The merits of using JavaScript are − ● Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server. ● Immediate feedback to the visitors − They don't have to wait for a page reload to see if they have forgotten to enter something. ● Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard. ● Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors. JavaScript Development Tools:- One of major strengths of JavaScript is that it does not require expensive development tools. You can start with a simple text editor such as Notepad. Since it is an interpreted language inside the context of a web browser, you don't even need to buy a compiler. To make our life simpler, various vendors have come up with very nice JavaScript editing tools. Some of them are listed here − ● Microsoft FrontPage − Microsoft has developed a popular HTML editor called FrontPage. FrontPage also provides web developers with a number of JavaScript tools to assist in the creation of interactive websites. ● Macromedia Dreamweaver MX − Macromedia Dreamweaver MX is a very popular HTML and JavaScript editor in the professional web development crowd. It provides several handy prebuilt JavaScript components, integrates well with databases, and conforms to new standards such as XHTML and XML. 2
  • 4. SOURAV NEWATIA(NIT KURUKSHETRA) Using JavaScript:- When used in a web page , the JavaScript scripting language works inside the ​web Browser Here are a Few examples of what you can do with JavaScript: - ​ Display ​information based on the time of day - ​Detect​ the visitor’s browser - ​Validate​ forms data - ​Create​ cookies - ​Change​ page contents dynamically - And much ​more​!!!!! 3
  • 5. SOURAV NEWATIA(NIT KURUKSHETRA) Others Uses Of JavaScript:- As Previously mentioned, JavaScript was designed to run as a scripting language, Inside the Web browser. But as JavaScript has become popular , you can find it in other ​applications​ (e.g.: Adobe Acrobat) and even server-side​ (e.g.: Node.js) products. Note:​- It is Recommended that you gain Basic knowledge of ​HTML​ and ​CSS​. 4
  • 6. SOURAV NEWATIA(NIT KURUKSHETRA) ​CREATING YOUR FIRST JAVASCRIPT:- JavaScript lives inside the HTML document.Below is a simple HTML document, with​ <head>​ and <body>​ tags , in which we will write our javascript code. In HTML, JavaScript code must be inserted between ​<script>​ and ​</script>​ tags : 5
  • 7. SOURAV NEWATIA(NIT KURUKSHETRA) JavaScript can be placed in the HTML page’s ​<body>​ and ​<head> ​sections. In the example below , we placed it within the ​<body>​ tag. Let’s use JavaScript to print ​“Hello World”​ to the browser. 6
  • 8. SOURAV NEWATIA(NIT KURUKSHETRA) The ​document.write()​ function writes a string into our HTML document.This function can be used to write text,HTML,or both. The Above code displays the following results:- Formatting Text :- Just like in HTML, we can use HTML tags to format text in JavaScript.For example, we can output the text as a heading. OUTPUT :- Hello World 7
  • 9. SOURAV NEWATIA(NIT KURUKSHETRA) ​ ADDING JAVASCRIPT TO A WEB PAGE:- javaScript in <head> :- You can place any number of scripts in an HTML document.Typically , the script tag is placed in the head of the HTML document: JavaScript in <body> :- You can place Alternatively , Include the JavaScript in the <body> tag. 8
  • 10. SOURAV NEWATIA(NIT KURUKSHETRA) The <Script> Tag :- The​ ​<script>​ ​tag can take two attributes, ​language​ and ​type​ , which specify the script’s type: In the example below , we created an alert box inside the script tag , using the​ alert() ​function. 9
  • 11. SOURAV NEWATIA(NIT KURUKSHETRA) ​ JavaScript Datatypes One of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language. JavaScript allows you to work with three primitive data types − ● Numbers,​ eg. 123, 120.50 etc. ● Strings​ of text e.g. "This text string" etc. ● Boolean​ e.g. true or false. JavaScript also defines two trivial data types, ​null and ​undefined, each of which defines only a single value. In addition to these primitive data types, JavaScript supports a composite data type known as ​object​. ​JavaScript Variables Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container. Before you use a variable in a JavaScript program, you must declare it. Variables are declared with the var keyword. 10
  • 12. SOURAV NEWATIA(NIT KURUKSHETRA) ​JavaScript Variable Scope:- The scope of a variable is the region of your program in which it is defined. JavaScript variables have only two scopes. ● Global Variables − A global variable has global scope which means it can be defined anywhere in your JavaScript code. ● Local Variables − A local variable will be visible only within a function where it is defined. Function parameters are always local to that function. Within the body of a function, a local variable takes precedence over a global variable with the same name. If you declare a local variable or function parameter with the same name as a global variable, you effectively hidethe global variable. 11
  • 13. SOURAV NEWATIA(NIT KURUKSHETRA) JavaScript - Functions A function is a group of reusable code which can be called anywhere in your program. This eliminates the need of writing the same code again and again. It helps programmers in writing modular codes. Functions allow a programmer to divide a big program into a number of small and manageable functions. Like any other advanced programming language, JavaScript also supports all the features necessary to write modular code using functions. You must have seen functions like alert() and write() in the earlier chapters. We were using these functions again and again, but they had been written in core JavaScript only once. Before we use a function, we need to define it. The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces. 12
  • 14. SOURAV NEWATIA(NIT KURUKSHETRA) Calling a Function: To invoke a function somewhere later in the script, you would simply need to write the name of that function as shown in the following code. Output:- 13
  • 15. SOURAV NEWATIA(NIT KURUKSHETRA) Function Parameters Till now, we have seen functions without parameters. But there is a facility to pass different parameters while calling a function. These passed parameters can be captured inside the function and any manipulation can be done over those parameters. A function can take multiple parameters separated by comma. Example Try the following example. We have modified our ​sayHello function here. Now it takes two parameters. Output:- 14
  • 16. SOURAV NEWATIA(NIT KURUKSHETRA) JavaScript - Events JavaScript's interaction with HTML is handled through events that occur when the user or the browser manipulates a page.When the page loads, it is called an event. When the user clicks a button, that click too is an event. Other examples include events like pressing any key, closing a window, resizing a window, etc. Developers can use these events to execute JavaScript coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated, and virtually any other type of response imaginable. onclick Event Type This is the most frequently used event type which occurs when a user clicks the left button of his mouse. You can put your validation, warning etc., against this event type. onsubmit Event Type: 15
  • 17. SOURAV NEWATIA(NIT KURUKSHETRA) onsubmit is an event that occurs when you try to submit a form. You can put your form validation against this event type. Example The following example shows how to use onsubmit. Here we are calling a ​validate() function before submitting a form data to the webserver. If ​validate() function returns true, the form will be submitted, otherwise it will not submit the data. 16
  • 18. SOURAV NEWATIA(NIT KURUKSHETRA) ​ ​HTML 5 Standard Events 17
  • 21. SOURAV NEWATIA(NIT KURUKSHETRA) JavaScript - Dialog Boxes JavaScript supports three important types of dialog boxes. These dialog boxes can be used to raise and alert, or to get confirmation on any input or to have a kind of input from the users. Alert Dialog Box An alert dialog box is mostly used to give a warning message to the users. For example, if one input field requires to enter some text but the user does not provide any input, then as a part of validation, you can use an alert box to give a warning message. Nonetheless, an alert box can still be used for friendlier messages. Alert box gives only one button "OK" to select and proceed. 20
  • 22. SOURAV NEWATIA(NIT KURUKSHETRA) OUTPUT:- Confirmation Dialog Box A confirmation dialog box is mostly used to take user's consent on any option. It displays a dialog box with two buttons: ​Cancel​. If the user clicks on the OK button, the window method ​confirm() will return true. If the user clicks on the Cancel button, then ​confirm() returns false. You can use a confirmation dialog box as follows. 21
  • 23. SOURAV NEWATIA(NIT KURUKSHETRA) Prompt Dialog Box The prompt dialog box is very useful when you want to pop-up a text box to get user input. Thus, it enables you to interact with the user. The user needs to fill in the field and then click OK. This dialog box is displayed using a method called ​prompt() which takes two parameters: (i) a label which you want to display in the text box and (ii) a default string to display in the text box. This dialog box has two buttons: ​OK and ​Cancel​. If the user clicks the OK button, the window method ​prompt() will return the entered value from the text box. If the user clicks the Cancel button, the window method ​prompt()​ returns ​null​. OUTPUT: 22
  • 24. SOURAV NEWATIA(NIT KURUKSHETRA) ​JavaScript - Debugging Every now and then, developers commit mistakes while coding. A mistake in a program or a script is referred to as a ​bug​. The process of finding and fixing bugs is called ​debugging and is a normal part of the development process. This section covers tools and techniques that can help you with debugging tasks.. Error Messages in IE The most basic way to track down errors is by turning on error information in your browser. By default, Internet Explorer shows an error icon in the status bar when an error occurs on the page. Double-clicking this icon takes you to a dialog box showing information about the specific error that occurred. Since this icon is easy to overlook, Internet Explorer gives you the option to automatically show the Error dialog box whenever an error occurs. To enable this option, select ​Tools → Internet Options → Advanced tab. and then finally check the ​"Display a Notification About Every Script Error"​ box option as shown below − 23
  • 25. SOURAV NEWATIA(NIT KURUKSHETRA) Error Messages in Firefox or Mozilla Other browsers like Firefox, Netscape, and Mozilla send error messages to a special window called the JavaScript Console or ​Error Consol​. To view the console, select ​Tools → Error Consol or Web Development​. 24
  • 26. SOURAV NEWATIA(NIT KURUKSHETRA) Disable JavaScript :- IN GOOGLE CHROME 1. Select the “Menu” button located at the upper-right corner of the screen, then select “Settings“, or type ​“chrome://settings/content“ in the address bar, press “Enter“, then skip to step 3. 2. Scroll down and select the “Show advanced settings…” option. 3. Select the “Content settings…” button. 4. Select “Allow all sites to run JavaScript” to enable JavaScript, select “Do not allow any site to run JavaScript” to disable it. 25
  • 27. SOURAV NEWATIA(NIT KURUKSHETRA) How To Create A Simple Calculator Using HTML And JavaScript:- All our calculator will do is basic arithmetic: add, subtract, multiply and divide. Hmm, what about negative numbers - so we also need to be able to change the sign of a number. What else? Well, we're going to allow rather big numbers, so it's a good idea to have a button that easily allows us to enter an exponent (the number times 10something). We need a decimal point. And we need to be able to clear the display (a CLEAR button), and to clear everything (ALL CLEAR). Let's list out requirements up to now: • A display area for numbers • Buttons for 0,1,2, up to 9 •A decimal point button • A button to change the sign (+/-) • Clear and all clear (C, AC buttons) • Function buttons (* / + -) • An exponent button (EXP) • A 'calculate' button (The = button) Let's group our different buttons and boxes into three classes: • The display area • The numeric buttons (0 to 9, +/-, .) • Function buttons together with AC, C, = and EXP 26
  • 31. SOURAV NEWATIA(NIT KURUKSHETRA) References:- (1) http://www.webestools.com/scripts_tutorials-code-sourc e-8-javascript-calculator-buttons-calculator-keyboard-sup port-operations-modulo.html (2) https://en.wikipedia.org/wiki/JavaScript (3) https://www.tutorialspoint.com/javascript/ (4) http://www.w3schools.com/js/ (5) https://www.sololearn.com/Course/JavaScript/ 30