This document discusses JavaScript, including its origins and differences from JScript and ECMA Script. JavaScript was originally created by Netscape as LiveScript but was renamed for marketing purposes. It has since been standardized as ECMAScript. While similar, JavaScript and Java are different languages. JavaScript is commonly used to add interactivity to web pages through events like onClick, onMouseOver, and onLoad. These events can be used in internet marketing to engage users. Camel case is a common convention for naming JavaScript files.
3. JavaScript
• JavaScript is THE scripting language of the Web.
• JavaScript is used in millions of Web pages to add
functionality, validate forms, detect browsers, and much
more.
• JavaScript is the most popular scripting language on the
internet, and works in all major browsers, such as
Internet Explorer, Firefox, Chrome, Opera, and Safari.
4. What can JavaScript do?
JavaScript gives HTML designers a programming tool
JavaScript can put dynamic text into an HTML page
JavaScript can react to events
JavaScript can read and write HTML elements
JavaScript can be used to validate data
JavaScript can be used to detect the visitor's browser
JavaScript can be used to create cookies
5. What are functions?
Functions contains code that
will be executed by an event or
by a call to the function.
7. An Alert Implemented
Inside a Function
<html>
Example: <head>
<script type="text/javascript">
function show_alert()
{
alert("I only exist to annoy you");
}
</script>
</head>
<body>
<input type="button" onclick="show_alert()"
value="Show alert box" />
</body>
</html>
Result:
8. Several Types of JavaScript Events
onLoad onClick
onMouseOver onMouseOut
9. What do the events do?
This creates an event when the user
onLoad enters the page.
This creates an event when the mouse is
onMouseOver passed over active text or image.
This creates an event when the mouse is
onMouseOut taken off of an active text image.
This creates an event when active text or
onClick images are clicked on.
10. onLoad example
Example: This what you see at
the end of a cookie
</script>
</head>
<body onload="checkCookie()">
</body>
</html>
Result:
11. onMouseOver example
Example:
<html>
<head>
<script type="text/javascript">
function writeText(txt)
{
document.getElementById("desc").innerHTML=txt;
Result:
}
</script>
</head>
<body>
<img src="planets.gif" width="145" height="126"
alt="Planets" usemap="#planetmap" />
<map name="planetmap">
<area shape ="rect" coords ="0,0,82,126"
onMouseOver="writeText('The Sun and the gas giant planets like Jupiter
are by far the largest objects in our Solar System.')"
href ="sun.htm" target ="_blank" alt="Sun" />
<area shape ="circle" coords ="90,58,3"
onMouseOver="writeText('The planet Mercury is very difficult to study
from the Earth because it is always so close to the Sun.')"
href ="mercur.htm" target ="_blank" alt="Mercury" />
<area shape ="circle" coords ="124,58,8"
onMouseOver="writeText('Until the 1960s, Venus was often considered a
twin sister to the Earth because Venus is the nearest planet to us, and
because the two planets seem to share many characteristics.')"
href ="venus.htm" target ="_blank" alt="Venus" />
</map> The Sun and the gas giant planets like Jupiter
<p id="desc"></p> are by far the largest objects in our Solar
</body>
System.
</html>
12. onMouseOut example
Example:
<html>
<head> Result:
<script type="text/javascript">
function writeText(txt)
{
document.getElementById("desc").innerHTML=txt;
}
</script>
</head>
<body>
<img src="planets.gif" width="145" height="126"
alt="Planets" usemap="#planetmap" />
<map name="planetmap">
<area shape ="rect" coords ="0,0,82,126"
onMouseOver="writeText('The Sun and the gas giant planets like Jupiter
The Sun and the gas giant planets like Jupiter
are by far the largest objects in our Solar System.')" are by far the largest objects in our Solar
href ="sun.htm" target ="_blank" alt="Sun" />
System.
<area shape ="circle" coords ="90,58,3"
onMouseOver="writeText('The planet Mercury is very difficult to study
from the Earth because it is always so close to the Sun.')"
href ="mercur.htm" target ="_blank" alt="Mercury" />
<area shape ="circle" coords ="124,58,8"
onMouseOver="writeText('Until the 1960s, Venus was often considered a
twin sister to the Earth because Venus is the nearest planet to us, and
because the two planets seem to share many characteristics.')"
href ="venus.htm" target ="_blank" alt="Venus" />
</map>
The planet Mercury is very difficult to study
<p id="desc"></p> from the Earth because it is always so close to
</body> the Sun.
</html>
13. onClick example
<html>
Example: <head>
<script type="text/javascript">
function displaymessage()
{
alert("Hello World!");
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" onclick="displaymessage()" />
</form>
<p>By pressing the button above, a function will be called. The function will alert a
message.</p>
</body>
</html>
Result:
14. How can an onLoad event be used
in Internet Marketing?
To get the customer to take action.
You might want them to buy
something,
or sign up for your newsletter!
To communicate and build a
relationship with the customer.
15. How can an onMouseOver event be
used in Internet Marketing?
To create tool tips, or to
add additional information
about a product or service.
16. How can an onMouseOut event be
used in Internet Marketing?
To bring the customer back
to the first selection.
To create interactivity for
the user.
17. How can an onClick event be used
in Internet Marketing?
To send the customer an alert
message.
To let the customer know, that
they have made
a purchase, signed up, or offer
additional savings!
18. What is Camel Case?
Camel Case is the use of upper-case letters
for each first letter of every word within a URL.
Example (standard URL):
www.jaimechristineperez.com
Example (Camel Case):
www.JaimeChristinePerez.com
19. File Naming Conventions
NAME
Online Training Library® » Adobe » Dreamweaver CS4 Essential Training » File naming
• Lynda video (lynda.com »
conventions)
20. Are Java and JavaScript the same?
JavaScript
JScript
NO!
Java and JavaScript are two completely different languages in both concept and design!
Java (developed by Sun Microsystems) is a powerful and much more complex
programming language.
22. JavaScript
• Netscape originally developed a
scripting language for use in its
browsers, calling it LiveScript.
• Java being an internet buzzword at
that time, for marketing reasons they
renamed the scripting language to
JavaScript.
• Brendan Eich (born 1961) is the
creator of the JavaScript
programming language.
• Now he is the Chief Technology
Officer at the Mozilla Corporation.
24. ECMAScript
• Netscape, Microsoft and others started
standardizing the scripting language, using the
ECMA standardizing organization for that.
• Thus the language standard is now called ECMA
Script.
• ECMA standard is only about the core language,
with data and objects like numbers, strings,
booleans, Object, Array, Function, Date, Math, but
NOT about application specific objects like browser
specific objects (document, window, links, images
etc).
• ECMA International
(http://www.ecma-international.org/)
25. ECMAScript
The Real Name is ECMAScript
• JavaScript's official name is ECMAScript.
• ECMAScript is developed and maintained by the ECMA
organization.
• ECMA-262 is the official JavaScript standard.
The language was invented and has appeared in all
1996 Netscape and Microsoft browsers.
1996 The development of ECMA-262 started.
The first edition of was adopted by the ECMA General
1997 Assembly in June 1997.
The standard was approved as an international ISO
1998 (ISO/IEC 16262) standard. ECMA International
(http://www.ecma-international.org/)
The development of the standard is still in progress.