Scripting languages

Download Report

Transcript Scripting languages

By Deborah Stone, Brian Wiley, and Jessi Wyatt
What is JavaScript?
• JavaScript is a simple scripting language
that can be embedded in the
<head>/<body> of your web pages. Doing
so you can create interactive web pages
by adding features such as:
– games
– customized graphics
– password protection – forms
– special effects
– and more
What is a
Scripting Language?
• Scripting languages (aka scripting
programming languages or script
languages) are computer programming
languages created to simplify the editcompile-link-run process.
What's the difference
between JavaScript and Java?
• Although, Java is technically an
interpreted programming language, it is
coded in a similar fashion to C++ (which
is a programming language.
• JavaScript is much simpler to use than
Java. No compiling, no applets, just a
simple sequence.
What can JavaScript do?
JavaScript can do the following:
•
•
•
•
•
•
•
Give HTML designers a programming tool
Put dynamic text into an HTML page
React to events
Read and write HTML elements
Validate data
Detect the visitor's browser
Create cookies
Sample Code: Password Protection
JavaScripts go in either the <head> or <body> tag, otherwise they won’t work.
<head>
<script type="text/javascript">  Tells your web browser you’re using JavaScript
<!-- Begin
password;  variable (password) that stores what you type
correct = “mypassword”;  variable (correct) that stores correct password
(mypassword).
password=prompt("Please enter your password:","");  the prompt that pops
up. What you type in is stored in the variable “password”.
if (password==correct) {  IF statement; compares both variables
window.location= "welcome.html"; file to open if password is correct
} else {  ELSE statement; what to do if passwords don’t match
window.location= "not_welcome.html";  file to load if password is incorrect
}
// End -->
</script>
</head>
Recap
• JavaScript is a scripting language that can make
your web pages interactive.
• A scripting language is a computer programming
language that can make your website
interactive.
• JavaScript & Java are totally different.
– JavaScript is much simpler to use than Java.
– Java is an interpreted programming language.
• JavaScript can be used for a variety of things
and you don’t have to know how to program to
use it. You can even get them for free online.
Additional Information
You can get free JavaScripts and tutorials
from the following websites:
• http://javascript.internet.com/
• http://www.webteacher.com/javascript/
• http://www.w3schools.com/js/