SlideShare a Scribd company logo
JAVASCRIPT POPUP BOXES
Zakho Technical Institute
IT Dept.
16-Feb.-2015
JAVASCRIPT POPUP BOXES
 There are three message boxes:
alert, confirm, and prompt. Let's look at the
first one:
ALERT
 An alert box is often used if you want to make sure
information comes through to the user.
 When an alert box pops up, the user will have to click
"OK" to proceed.
 <body>
 <script>
 alert("Welcome to my site!")
 </script>
 </body>
You can put whatever you want inside the quotation marks.
CONFIRM
 <body>
 <script>
 confirm("Are you sure you want to quit?")
 </script>
 </body>
PROMPT
 Prompt box is used to allow a user to enter
something according the promotion:
EXAMPLE
 <script>
 var x=confirm("Are you sure you want to
quit")
 if (x)
 alert("Thank you.")
 else
 alert("Good choice.")
 </script>
EXAMPLE
 <html><head> <script>
 var x=confirm("Are you sure you want to
quit?")
 if (!x)
 location="http://www.yahoo.com"
</script></head>
 <body> Welcome to my website!.
 </body></html>If you click "cancel", it will take you to yahoo, and clicking ok will continue with the loading
of the current page "Welcome to my website!". Note:if (!x)means: if click "cancel". In
JavaScript, the exclamation mark ! means: "none".
EVENT HANDLER
 What are event handlers?
They can be considered as triggers that
execute JavaScript when something
happens, such as click or move your mouse
over a link, submit a form etc.
 onClick
onClick handlers execute something only when
users click on buttons, links, etc. Let's see an
example:
 <script>
 function ss()
 { alert("Thank you!") }
 </script>
 <form>
 <input type="button" value="Click here"
onclick="ss()">
 </form>
The function ss() is invoked when the user clicks the button. Note: Event
handlers are not added inside the<script> tags, but rather, inside the html
tags.
JAVASCRIPT SPECIAL CHARACTERS
 In JavaScript you can add special characters to a
text string byInsert Special Characters
 The backslash () is used to insert apostrophes,
new lines, quotes, and other special characters
into a text string.
 Look at the following JavaScript code:
 using the backslash sign.
EXAMPLE
 var txt="We are the so-called "Vikings" from
the north.";
document.write(txt);
 In JavaScript, a string is started and stopped
with either single or double quotes. This means
that the string above will be chopped to:
We are the so-called
 To solve this problem, you must place a
backslash () before each double quote in
"Viking". This turns each double quote into a
string literal:
EXAMPLE
 var txt="We are the so-called "Vikings" from
the north.";
document.write(txt);
 JavaScript will now output the proper text
string: We are the so-called "Vikings" from
the north.
 The table below lists other special characters
that can be added to a text string with the
backslash sign:
TABLE
BREAK UP LINE
 document.write("Hello World!");
 or
 document.write ("Hello World!");
 which is right ...?
ARRAY
 Create an Array
 An array can be defined in three ways.
 The following code creates an Array object
called myCars:
 var myCars=new Array(); // regular array (add
an optional integer
myCars[0]="Saab"; // argument to control
array's size)
myCars[1]="Volvo";
myCars[2]="BMW";
ARRAY
 var myCars=new
Array("Saab","Volvo","BMW"); // condensed
array
 var myCars=["Saab","Volvo","BMW"]; // literal
array
ACCESS AN ARRAY
 You can refer to a particular element in an
array by referring to the name of the array
and the index number. The index number
starts at 0.
 The following code line:
 Document.write(myCars[0]);
 will result in the following output:
 Saab
EXAMPLE
 Create an array for Web shoppe contains 5
element:
 customer's name
 customer's date of birth
 customer's address
 customer's phone number
 total bill amount
THAT’S IT ...
?
☺
Yes No
QUESTIONS GAME .....
 Choose ur favourite no.
1
2
15
3
4
5
6
7
8
9
10
12
16
14
12
13
1
11
1
 True or false :
 JS is usually embedded directly into html
pages ................
2
 How can u write a comments in JS ....?
3
 The “radio” element used for selecting one of
many choice ....>>>>> T or F ......
4
 The <txet area> defines a multiline input field
(a text area)..
T or F
5
 The “checkbox” is the same as
“radiobutton”...
 T or F
6
 In CSS .... Border clear an area around
the contents ..
 T or F .. Correct if F
7
 What is the full word of HTML .....?
8
 JS is sensitive for letter ....isn’t it ?explain
9
 Define .......
“World Wide Web”
10
 Http mean” Hyper ......... ........ ........”
11
 Can you clarify the meaning of “URL” ..?
12
 What is CSS ?
13
 Clarify with example the syntax of CSS ...
14
 The id selector is defined with “{“ ...
 T or F
15
 What are event handlers?
16
 How many message boxes did we have in
JS ?
 Explain with examples......
Message Box in JS

More Related Content

DOCX
Java script
PPTX
Form Validation in JavaScript
PPT
Html5 new input attributes (@nzin4x)
PPT
Form validation client side
PPTX
WP7 HUB_Diseño del interfaz con Silverlight
ODP
Tut 06 (forms)
PPTX
Form using html and java script validation
PPTX
Php Form
Java script
Form Validation in JavaScript
Html5 new input attributes (@nzin4x)
Form validation client side
WP7 HUB_Diseño del interfaz con Silverlight
Tut 06 (forms)
Form using html and java script validation
Php Form

What's hot (12)

PPTX
Java script basic
PPTX
Javascript validating form
PPTX
HTML Forms Tutorial
PPTX
html forms
PPT
Form validation server side
PDF
Creating a Simple, Accessible On/Off Switch
PPTX
Html forms
PDF
phptut2
PDF
Creating an Accessible button dropdown
PDF
2. HTML forms
PPT
05 html-forms
PDF
Web application security
Java script basic
Javascript validating form
HTML Forms Tutorial
html forms
Form validation server side
Creating a Simple, Accessible On/Off Switch
Html forms
phptut2
Creating an Accessible button dropdown
2. HTML forms
05 html-forms
Web application security
Ad

Similar to Message Box in JS (20)

PPT
FSJavaScript.ppt
PPTX
Javascript
PPTX
Java script basics
PPTX
Web programming
DOCX
PDF
Web Application Security
PDF
PDF
Javascript part1
PPTX
Java script
PPTX
FYBSC IT Web Programming Unit III Javascript
PPTX
wp-UNIT_III.pptx
PPTX
1. java script language fundamentals
PPTX
Web designing unit 4
RTF
Java scripts
PPTX
Popup boxes
PPTX
Gutmacher practical-coding-examples-for-sourcers-sc18 atl
PPTX
Java script
PPTX
JavaScript 101
PPTX
Unit III.pptx IT3401 web essentials presentatio
PPTX
Javascript note for engineering notes.pptx
FSJavaScript.ppt
Javascript
Java script basics
Web programming
Web Application Security
Javascript part1
Java script
FYBSC IT Web Programming Unit III Javascript
wp-UNIT_III.pptx
1. java script language fundamentals
Web designing unit 4
Java scripts
Popup boxes
Gutmacher practical-coding-examples-for-sourcers-sc18 atl
Java script
JavaScript 101
Unit III.pptx IT3401 web essentials presentatio
Javascript note for engineering notes.pptx
Ad

Recently uploaded (20)

PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
innovation process that make everything different.pptx
PDF
Sims 4 Historia para lo sims 4 para jugar
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
Paper PDF World Game (s) Great Redesign.pdf
PPTX
Funds Management Learning Material for Beg
PPTX
Mathew Digital SEO Checklist Guidlines 2025
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PPTX
E -tech empowerment technologies PowerPoint
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
Exploring VPS Hosting Trends for SMBs in 2025
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PPTX
international classification of diseases ICD-10 review PPT.pptx
An introduction to the IFRS (ISSB) Stndards.pdf
innovation process that make everything different.pptx
Sims 4 Historia para lo sims 4 para jugar
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Module 1 - Cyber Law and Ethics 101.pptx
Paper PDF World Game (s) Great Redesign.pdf
Funds Management Learning Material for Beg
Mathew Digital SEO Checklist Guidlines 2025
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Tenda Login Guide: Access Your Router in 5 Easy Steps
E -tech empowerment technologies PowerPoint
Decoding a Decade: 10 Years of Applied CTI Discipline
Exploring VPS Hosting Trends for SMBs in 2025
Introuction about WHO-FIC in ICD-10.pptx
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
SASE Traffic Flow - ZTNA Connector-1.pdf
Introuction about ICD -10 and ICD-11 PPT.pptx
Power Point - Lesson 3_2.pptx grad school presentation
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
international classification of diseases ICD-10 review PPT.pptx

Message Box in JS

  • 1. JAVASCRIPT POPUP BOXES Zakho Technical Institute IT Dept. 16-Feb.-2015
  • 2. JAVASCRIPT POPUP BOXES  There are three message boxes: alert, confirm, and prompt. Let's look at the first one:
  • 3. ALERT  An alert box is often used if you want to make sure information comes through to the user.  When an alert box pops up, the user will have to click "OK" to proceed.  <body>  <script>  alert("Welcome to my site!")  </script>  </body> You can put whatever you want inside the quotation marks.
  • 4. CONFIRM  <body>  <script>  confirm("Are you sure you want to quit?")  </script>  </body>
  • 5. PROMPT  Prompt box is used to allow a user to enter something according the promotion:
  • 6. EXAMPLE  <script>  var x=confirm("Are you sure you want to quit")  if (x)  alert("Thank you.")  else  alert("Good choice.")  </script>
  • 7. EXAMPLE  <html><head> <script>  var x=confirm("Are you sure you want to quit?")  if (!x)  location="http://www.yahoo.com" </script></head>  <body> Welcome to my website!.  </body></html>If you click "cancel", it will take you to yahoo, and clicking ok will continue with the loading of the current page "Welcome to my website!". Note:if (!x)means: if click "cancel". In JavaScript, the exclamation mark ! means: "none".
  • 8. EVENT HANDLER  What are event handlers? They can be considered as triggers that execute JavaScript when something happens, such as click or move your mouse over a link, submit a form etc.
  • 9.  onClick onClick handlers execute something only when users click on buttons, links, etc. Let's see an example:  <script>  function ss()  { alert("Thank you!") }  </script>  <form>  <input type="button" value="Click here" onclick="ss()">  </form> The function ss() is invoked when the user clicks the button. Note: Event handlers are not added inside the<script> tags, but rather, inside the html tags.
  • 10. JAVASCRIPT SPECIAL CHARACTERS  In JavaScript you can add special characters to a text string byInsert Special Characters  The backslash () is used to insert apostrophes, new lines, quotes, and other special characters into a text string.  Look at the following JavaScript code:  using the backslash sign.
  • 11. EXAMPLE  var txt="We are the so-called "Vikings" from the north."; document.write(txt);  In JavaScript, a string is started and stopped with either single or double quotes. This means that the string above will be chopped to: We are the so-called  To solve this problem, you must place a backslash () before each double quote in "Viking". This turns each double quote into a string literal:
  • 12. EXAMPLE  var txt="We are the so-called "Vikings" from the north."; document.write(txt);  JavaScript will now output the proper text string: We are the so-called "Vikings" from the north.  The table below lists other special characters that can be added to a text string with the backslash sign:
  • 13. TABLE
  • 14. BREAK UP LINE  document.write("Hello World!");  or  document.write ("Hello World!");  which is right ...?
  • 15. ARRAY  Create an Array  An array can be defined in three ways.  The following code creates an Array object called myCars:  var myCars=new Array(); // regular array (add an optional integer myCars[0]="Saab"; // argument to control array's size) myCars[1]="Volvo"; myCars[2]="BMW";
  • 16. ARRAY  var myCars=new Array("Saab","Volvo","BMW"); // condensed array  var myCars=["Saab","Volvo","BMW"]; // literal array
  • 17. ACCESS AN ARRAY  You can refer to a particular element in an array by referring to the name of the array and the index number. The index number starts at 0.  The following code line:  Document.write(myCars[0]);  will result in the following output:  Saab
  • 18. EXAMPLE  Create an array for Web shoppe contains 5 element:  customer's name  customer's date of birth  customer's address  customer's phone number  total bill amount
  • 20. QUESTIONS GAME .....  Choose ur favourite no. 1 2 15 3 4 5 6 7 8 9 10 12 16 14 12 13 1 11
  • 21. 1  True or false :  JS is usually embedded directly into html pages ................
  • 22. 2  How can u write a comments in JS ....?
  • 23. 3  The “radio” element used for selecting one of many choice ....>>>>> T or F ......
  • 24. 4  The <txet area> defines a multiline input field (a text area).. T or F
  • 25. 5  The “checkbox” is the same as “radiobutton”...  T or F
  • 26. 6  In CSS .... Border clear an area around the contents ..  T or F .. Correct if F
  • 27. 7  What is the full word of HTML .....?
  • 28. 8  JS is sensitive for letter ....isn’t it ?explain
  • 30. 10  Http mean” Hyper ......... ........ ........”
  • 31. 11  Can you clarify the meaning of “URL” ..?
  • 32. 12  What is CSS ?
  • 33. 13  Clarify with example the syntax of CSS ...
  • 34. 14  The id selector is defined with “{“ ...  T or F
  • 35. 15  What are event handlers?
  • 36. 16  How many message boxes did we have in JS ?  Explain with examples......

Editor's Notes

  • #22: TRue
  • #23: //
  • #24: T
  • #25: F
  • #26: F
  • #27: F “Padding” Or Contents and padding
  • #28: Hyper text markup lang
  • #30: The internet
  • #32: Uniform Resource Locator 1- protocol part 2-host part 3-document part
  • #33: Cascade style sheet Styles defines how to display html elements
  • #34: H1 {color:blue;font-size:12px;} Selector proprty:value
  • #35: F #