SlideShare a Scribd company logo
1 of 28
Introduction to JavaScript Events
As usual, please use the speaker notes
for additional information!
Cautions!
• JavaScript is very case sensitive
• JavaScript should have each command
written on one line
• To be able to see source code effectively, I
use Explorer
CISaCISb.htmlCISaCISb.html
<HTML>
<HEAD>
<TITLE>Rollover</TITLE>
</HEAD>
<BODY>
<P ALIGN=RIGHT>
<A HREF="#" onMouseOver = "alert('Testing mouse over!');">
<FONT SIZE=12>Mouse over here!</FONT></A></P>
Some of the first interesting things you can do with JavaScript are event-driven. Event
driven means that a particular action causes something to happen. JavaScript has licks that
can detect events such as onClick, onMouseOver, onMouseOut. This page illustrates the
mouse over and mouse out events.<BR><BR><BR>
<A HREF="#"
onMouseOver="document.CISimage.src='CISa.gif';"
onMouseOut="document.CISimage.src='CISb.gif';">
<IMG SRC="CISa.gif" NAME="CISimage"></A>
<BR><BR>
In this case, the onMouseOver
will bring up an alert message
box . Note the use of quotes, the
semicolon and the parenthesis
which go with the alert()
function.
# in the A HREF
means same page.
CISaCISb.htmlCISaCISb.html
In this example onMouseOver
shows one image and onMouseOut
shows a different image. Note that
CISimage is the name associated
with the image that shows when
the code is loaded. Again, note the
use on quotation makes and semi-
colons and the < > in the HTML
surrounding the JavaScript.
CISaCISb.htmlCISaCISb.html
Notice that the # means this page to HTML and so setting the HREF to the # means stay on the same page. You can
also use the name of the current page.<BR> Now looking at the construction of the command. Note that
onMouseOver should be written exactly that way because of case sensitivity issues. In the first example, I am saying
the mouse roles over the words Mouse over here!, then the alert box will come up with the message that says Testing
mouse over. Notice the use of the double quote, single quotes, parenthesis and semi-colon. Inside the double quotes
is the JavaScript comman which should end with a semi-colon. What we are doing is putting the JavaScript inside
the
quotes of an event. The event is onMouseOver. The alert needs a message and the message inside parenthesis and
enclosed in single quotes. If you have quotes within quotes the inner quotes must be single to differentiate. The
alert() function puts the message in the () inside the message box. Note that all functions in JavaScript have the form
functionName() where sometimes the parenthesis contain data and sometimes they are empty. We will see more of
this in later examples. Note one last thing that has nothing to do with JavaScript, because I wanted to Mouse over
here! to be large and aligned to the right, I used the paragraph to align to the right and the font to change the font.
These are not needed for the JavaScript.<BR>
On the next example, I am using both onMouseOver and onMouseOut. I went into PhotoEditor and did a invert with
the CISa.gif image and saved it as CISb.gif. Then I can have one image show when the mouse rolls over the image
and a second image show when the mouse rolls out.<BR>
When I work with an image, I need to be aware of the fact that frequently browers will not let the developer put
events inside image tags. So what you have to do is set up the HREF equal to # and put the events inside that and
then set up the image source with name as shown above. When the image is firstloaded it will show the image in
IMG SRC which in this case is CISa.gif. When the mouse goes over that same image is shown. When the mouse
goes out a different image is shown (in this case the inverted image). The dots in document.CISimage.src have
special meaning to JavaScript. It will go to the last dot and work backward in the interpretation. So this essentially
reads as change the src of CISimage which is in the document. This follows a document object model hierarchy
(DOM) which can be referenced in many tutorials on JavaScript.<BR> To make things more efficient you can
preload the images. I will illustrate a preload in another example.<BR>
One other thing to note - because single and double quotes have special meanings, you cannot use them in the
ordinary way in your text. If you want to use the quotes in your text you do it with Jane's where the  tells JavaScript
to use the single quote instead of interpreting it.
CISaCISb1.htmlCISaCISb1.html
<HTML>
<HEAD>
<TITLE>More events in JavaScript</TITLE>
<SCRIPT language="JavaScript">
var CISa_image = new Image();
CISa_image.src = "CISa.gif";
var CISb_image = new Image();
CISb_image.src = "CISb.gif";
</SCRIPT>
The word var is optional - however if used it should be lower case.
When I write this program with VAR I get an error in explorer about missing ; which
essentially means their is a problem with the code.
</HEAD>
<BODY>
The code above preloads two images.<BR>
<A HREF="#"
onMouseOver="CISimage.src='CISa.gif';"
onMouseOut="CISimage.src='CISb.gif';">
<IMG SRC="CISb.gif" NAME="CISimage" BORDER = 0></A>
</BODY>
</HTML>
CISaCISb1.htmlCISaCISb1.html
Load the images. The
variable name where they
are put are CISa_image and
CISb_image.
This time the CISb.gif is
loaded when the form is shown.
In this example I am simply giving
the image name.
<HTML>
<HEAD>
<TITLE>Java rotate</TITLE>
<SCRIPT>
originalz = new Image;
originalz.src="house.jpg";
flipz = new Image;
flipz.src = "houseusd.jpg";
</SCRIPT>
</HEAD>
<BODY bgcolor=beige>
<DIV ALIGN=CENTER>
<H1>Here is an image to roll the mouse over</H1>
<H3>Rolling the mouse over and out are called events.</H3>
<A HREF="javamouse.html"
onMouseOver="document.myhouse.src = flipz.src"
onMouseOut="document.myhouse.src = originalz.src">
<IMG SRC="house.jpg"
NAME="myhouse"></A>
</DIV>
</BODY>
</HTML>
javamouse.htmljavamouse.html
This code establishes a new Image called
originalz and then specifies the source for this
image as house.jpg.
It then establishes another new image called flipz
and then specifies that the source for this image is
houseusd.jpg.
The events are associated with the A HREF which refers
to this page. The events say take the current document or
window and then the name associated with the image and
make the source the sources that were specified in the
<HEAD>.
This means
the original
image shown
is house.jpg
Document refers to the
object of the window that is
being worked with.
Note I
used
the
defined
image
name
and not
the .jpg
name.
<HTML>
<HEAD>
<TITLE>Java rotate</TITLE>
<SCRIPT language = "JavaScript">
<!--hide from browser that do not support
var originalz = new Image;
originalz.src="house.jpg";
var flipz = new Image;
flipz.src = "houseusd.jpg";
// end of the hide -->
</SCRIPT>
</HEAD>
<BODY bgcolor=beige>
<DIV ALIGN=CENTER>
<H1>Here is an image to roll the mouse over</H1>
<H3>Rolling the mouse over and out are called events.</H3>
<A HREF="javamouse.html"
onMouseOver="document.myhouse.src = flipz.src;"
onMouseOut="document.myhouse.src = originalz.src;">
<IMG SRC="house.jpg"
NAME="myhouse"></A>
</DIV>
Here are a few comments on the program.
<UL>
<LI>I did not include langauge = "JavaScript" in
the SCRIPT of the original program because it is not required. It is a good thing to do
because other languages can be used for scripting, such as VB.
<LI>This code includes the Hide me if the browser does not support JavaScript code.
<LI>var is not required so I did not use it in the previous example.
<LI>the semi-colons are not required after the mouse over and out and I did not use them
in the previous example
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>Events in Java</TITLE>
</HEAD>
<BODY bgcolor=aqua>
<H3>Events are a different type of Java code because they are built directly into the HTML code.
They aren't scripts because their design was to be embedded in the HTML. First I am
going to illustrate mouse over/out events.</H3>
<P ALIGN=CENTER>
<A HREF="tryevent1.html"
onMouseOver="alert('Testing events...')">ALERT MOUSE TEST!</A>
<BR><BR>
<A HREF="tryevent1.html"
onMouseOver="document.bgColor='beige'">CHANGE BACKGROUND TO BEIGE!</A>
<BR><BR>
<A HREF="tryevent1.html"
onMouseOver="document.bgColor='aqua'">CHANGE BACKGROUND TO AQUA!</A>
<BR><BR>
<A HREF="tryevent1.html"
onMouseOver="document.bgColor='pink'"
onMouseOut="document.bgColor='green'">CHANGE BACKGROUND!</A>
<BR><BR>
<A HREF="tryevent1.html"
onMouseOver="window.status='Testing roll over'; return true"
onMouseOut="window.status='Testing roll out'; return true">WINDOW STATUS TRUE TEST!</A>
<BR><BR>
<A HREF="tryevent1.html"
onMouseOver="window.status='Testing roll over'"
onMouseOut="window.status='Testing roll out'">WINDOW STATUS TEST!</A>
<BR><BR>
Note: The return true clause allows the default in the window status to be over ridden.
</P>
</BODY>
</HTML>
tryevent1.htmltryevent1.html
Different things are happening as a result of the onMouseOver
event. In the first example, a popup alert window comes up. In
the second the background changes to beige.
<A HREF="tryevent1.html"
onMouseOver="alert('Testing events...')">ALERT MOUSE TEST!</A>
This slide shows the result of
moving the mouse over the
ALERT MOUSE TEST. The
code behind this line is shown
below.
<A HREF="tryevent1.html"
onMouseOver="document.bgColor='beige'">CHANGE BACKGROUND TO BEIGE!</A>
This shows the results of running
the mouse over CHANGE
BACKGROUND TO BEIGE!
The code is shown below.
Note that “document.bgcolor=‘beige’” is enclosed in double quotes
and the word ‘beige’ is enclosed in single quotes because it is
embedded in double quotes and trying to use double quotes would
confuse the structure of the command.
<A HREF="tryevent1.html"
onMouseOver="window.status='Testing roll over'; return true"
onMouseOut="window.status='Testing roll out'; return true">WINDOW STATUS TRUE TEST!</A>
<A HREF="tryevent1.html"
onMouseOver="window.status='Testing roll over'; return true"
onMouseOut="window.status='Testing roll out'; return true">WINDOW STATUS TRUE TEST!</A>
<A HREF="tryevent1.html"
onMouseOver="window.status='Testing roll over'"
onMouseOut="window.status='Testing roll out'">WINDOW STATUS TEST!</A>
<BODY bgcolor=pink onLoad="alert('WELCOME!')">
<HTML>
<HEAD>
<TITLE>Events in Java</TITLE>
</HEAD>
<BODY bgcolor=pink onLoad="alert('WELCOME!')">
<H3>This example illustrates the on click event.</H3>
<P ALIGN=CENTER>
<A HREF="tryevent2.html"
onClick="alert('Testing events...')">ALERT ON CLICK TEST!</A>
<BR><BR>
</P>
<H3>Using onFocus, when you click on the box in the form, the window will display the
activity to be done.</H3>
<H3>Using onChange tells when the data has been changed.</H3>
<FORM NAME="crsform">
Course information:
<INPUT TYPE="text" SIZE=5 NAME="crscode"
onFocus="window.status='Enter course code'">
<INPUT TYPE="text" SIZE=25 NAME="crsname"
onFocus="window.status='Enter course name'";
onChange="alert('The data has been changed')";>
<BR><BR>
<P>MAJOR:<BR>
<INPUT TYPE="RADIO" NAME="major" VALUE="CI">Computer Information Systems<BR>
<INPUT TYPE="RADIO" NAME="major" VALUE="BU">Business Administration<BR>
<INPUT TYPE="RADIO" NAME="major" VALUE="other">Other major<BR>
<H3>The onBlur means that you have lost focus on an answer.</H3>
<INPUT TYPE="text" SIZE=25 NAME="crsinst"
onFocus="window.status='Enter instructor name'";
onBlur="alert('Did you enter instructor name?')";>
<P>Comments:<BR>
<TEXTAREA ROWS="6" COLS="40" NAME="Comments"></TEXTAREA>
<P>
<INPUT TYPE="RESET" VALUE="Clear">
<P>
<INPUT TYPE="BUTTON" VALUE="Back" onClick="history.go(-1)">
<INPUT TYPE="BUTTON" VALUE="Forward" onClick="history.go(1)">
</FORM>
</BODY>
</HTML>
tryevent2.htmltryevent2.html
<INPUT TYPE="text" SIZE=5 NAME="crscode"
onFocus="window.status='Enter course code'">
<INPUT TYPE="text" SIZE=25 NAME="crsname"
onFocus="window.status='Enter course name'";
onChange="alert('The data has been changed')";>
<INPUT TYPE="text" SIZE=25 NAME="crsinst"
onFocus="window.status='Enter instructor name'";
onBlur="alert('Did you enter instructor name?')";>
<INPUT TYPE="BUTTON" VALUE="Back" onClick="history.go(-1)">
<INPUT TYPE="BUTTON" VALUE="Forward" onClick="history.go(1)">
<HTML>
<HEAD>
<TITLE>More events</TITLE>
<SCRIPT language="JavaScript">
var mycolor;
var myfont;
</SCRIPT>
</HEAD>
<BODY>
<H2>This shows some uses of the onClick event</H2>
<IMG SRC="CISa.gif" NAME="originalz"><BR>
<A HREF = "#"
onClick="window.document.bgColor='beige'";>Make background beige</A><BR>
<A HREF = "#"
onClick="window.document.fgColor='blue'";>Make font blue</A><BR>
<A HREF="#"
onClick="mycolor=prompt('Enter your choice of background color','');
window.document.bgColor=mycolor;">Change the background color</A><BR>
<A HREF="#"
onClick="myfont=prompt('Enter your choice of font color','');
window.document.fgColor=myfont;">Change the font color</A><BR>
<A HREF="#"
onClick="document.originalz.src='CISb.gif';">Click here to change the top image!</A><BR>
<A HREF="#"
onClick="document.originalz.src='CISa.gif';
return false;">Click here to change the top image back!</A><BR>
onClick.htmlonClick.html
The prompt calls for title, data for
the input box. In the first case, I
want nothing in the input box. In the
second case I am using a default of
pink. This is shown on the next
page.
Note: Return false is another way to tell the browser not to follow the link given.<BR>
The Prompt puts up a box where the user can enter input. Note that in the prompt I have
some words that will become the title, then I entered a comma and two quotes together. The
two quotes together make the box where I want the user to enter information blank. If
I wanted to put a default in the user entry line I could put in between the quotes.<BR>
<A HREF="#"
onClick="mycolor=prompt('Enter your choice of background color','pink');
window.document.bgColor=mycolor;">Change the background color</A><BR>
Note also that there are two things that I want to do on the click event, one is to get
the user to pick a color or in this case, go with the default. The other is to use that
color to change the background. The double quotes are around both of these.
</BODY>
</HTML>
onClick.htmlonClick.html
<HTML>
<HEAD>
<TITLE>Javascript font experiment</TITLE>
</HEAD>
<BODY BGCOLOR=beige>
This is an experiment with Javascript and font useage. Note that in javascript terms, the
document is an object and the write statement that I am going to include below is a method
or in other words an action that is executed on the document. When I do the write below,
color and the size are being done to the document at a particular time and this is an instance.
Objects can also have properties related to them as shown in the example after dealing
with fonts.
<BR><BR>
<SCRIPT LANGUAGE="javascript">
document.write("<FONT COLOR='GREEN' SIZE=150%>This is green font</FONT>")
</SCRIPT>
<BR><BR>
Now I am going to try this without the double quotes around the whole. You can see that this
doesn't work. Essentially the material inside the double quotes will be written to the screen
and the HTML code that is included will be executed. Notice that the attempt to get red font
below does not work because the double quotes around FONT are missing.
<BR><BR>
<SCRIPT LANGUAGE="javascript">
document.write(<FONT COLOR="RED" SIZE=150%>This is red font</FONT>)
</SCRIPT>
Note also since I am using double quotes outside. I need to use single quotes or no quotes
inside for the color.
<BR><BR>
<SCRIPT LANGUAGE="javascript">
document.write("<FONT COLOR=BLUE SIZE=150%>This is blue font</FONT>")
</SCRIPT>
Font1.htmlFont1.html

More Related Content

What's hot

Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
Scott Messinger
 

What's hot (20)

Ajax
AjaxAjax
Ajax
 
Java script basics
Java script basicsJava script basics
Java script basics
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
 
React
React React
React
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
 
Building a Startup Stack with AngularJS
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
 
JavaScript
JavaScriptJavaScript
JavaScript
 
1cst
1cst1cst
1cst
 
Bootstrap과 UI-Bootstrap
Bootstrap과 UI-BootstrapBootstrap과 UI-Bootstrap
Bootstrap과 UI-Bootstrap
 
HTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymoreHTML5: where flash isn't needed anymore
HTML5: where flash isn't needed anymore
 
Thomas Fuchs Presentation
Thomas Fuchs PresentationThomas Fuchs Presentation
Thomas Fuchs Presentation
 
Mobile optimization
Mobile optimizationMobile optimization
Mobile optimization
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
SocketStream
SocketStreamSocketStream
SocketStream
 
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS»  QADay 2019МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS»  QADay 2019
МИХАЙЛО БОДНАРЧУК «SuperCharged End to End Testing with CodeceptJS» QADay 2019
 
JavaScript: DOM and jQuery
JavaScript: DOM and jQueryJavaScript: DOM and jQuery
JavaScript: DOM and jQuery
 
Java scripts
Java scriptsJava scripts
Java scripts
 
Spa, isomorphic and back to the server our journey with js @ frontend con po...
Spa, isomorphic and back to the server  our journey with js @ frontend con po...Spa, isomorphic and back to the server  our journey with js @ frontend con po...
Spa, isomorphic and back to the server our journey with js @ frontend con po...
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
 
Clean Javascript
Clean JavascriptClean Javascript
Clean Javascript
 

Similar to POLITEKNIK MALAYSIA

JAVASCRIPT 1.pptx.pptx
JAVASCRIPT 1.pptx.pptxJAVASCRIPT 1.pptx.pptx
JAVASCRIPT 1.pptx.pptx
BeingPrime
 
4007655 introduction-to-javascript
4007655 introduction-to-javascript4007655 introduction-to-javascript
4007655 introduction-to-javascript
Vikash Chandra
 

Similar to POLITEKNIK MALAYSIA (20)

JAVASCRIPT 1.pptx.pptx
JAVASCRIPT 1.pptx.pptxJAVASCRIPT 1.pptx.pptx
JAVASCRIPT 1.pptx.pptx
 
Events Lecture Notes
Events Lecture NotesEvents Lecture Notes
Events Lecture Notes
 
Site optimization
Site optimizationSite optimization
Site optimization
 
JavaScript with Syntax & Implementation
JavaScript with Syntax & ImplementationJavaScript with Syntax & Implementation
JavaScript with Syntax & Implementation
 
4007655 introduction-to-javascript
4007655 introduction-to-javascript4007655 introduction-to-javascript
4007655 introduction-to-javascript
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Client Web
Client WebClient Web
Client Web
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFGStHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
StHack 2014 - Mario "@0x6D6172696F" Heiderich - JSMVCOMFG
 
jQuery
jQueryjQuery
jQuery
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Web performance essentials - Goodies
Web performance essentials - GoodiesWeb performance essentials - Goodies
Web performance essentials - Goodies
 
Devoxx 2014-webComponents
Devoxx 2014-webComponentsDevoxx 2014-webComponents
Devoxx 2014-webComponents
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
JavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptxJavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptx
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Java Script
Java ScriptJava Script
Java Script
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Reacting to a Virtual World
Reacting to a Virtual WorldReacting to a Virtual World
Reacting to a Virtual World
 
Assignment D
Assignment DAssignment D
Assignment D
 

More from Aiman Hud

More from Aiman Hud (20)

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

POLITEKNIK MALAYSIA

  • 1. Introduction to JavaScript Events As usual, please use the speaker notes for additional information!
  • 2. Cautions! • JavaScript is very case sensitive • JavaScript should have each command written on one line • To be able to see source code effectively, I use Explorer
  • 4. <HTML> <HEAD> <TITLE>Rollover</TITLE> </HEAD> <BODY> <P ALIGN=RIGHT> <A HREF="#" onMouseOver = "alert('Testing mouse over!');"> <FONT SIZE=12>Mouse over here!</FONT></A></P> Some of the first interesting things you can do with JavaScript are event-driven. Event driven means that a particular action causes something to happen. JavaScript has licks that can detect events such as onClick, onMouseOver, onMouseOut. This page illustrates the mouse over and mouse out events.<BR><BR><BR> <A HREF="#" onMouseOver="document.CISimage.src='CISa.gif';" onMouseOut="document.CISimage.src='CISb.gif';"> <IMG SRC="CISa.gif" NAME="CISimage"></A> <BR><BR> In this case, the onMouseOver will bring up an alert message box . Note the use of quotes, the semicolon and the parenthesis which go with the alert() function. # in the A HREF means same page. CISaCISb.htmlCISaCISb.html In this example onMouseOver shows one image and onMouseOut shows a different image. Note that CISimage is the name associated with the image that shows when the code is loaded. Again, note the use on quotation makes and semi- colons and the < > in the HTML surrounding the JavaScript.
  • 5. CISaCISb.htmlCISaCISb.html Notice that the # means this page to HTML and so setting the HREF to the # means stay on the same page. You can also use the name of the current page.<BR> Now looking at the construction of the command. Note that onMouseOver should be written exactly that way because of case sensitivity issues. In the first example, I am saying the mouse roles over the words Mouse over here!, then the alert box will come up with the message that says Testing mouse over. Notice the use of the double quote, single quotes, parenthesis and semi-colon. Inside the double quotes is the JavaScript comman which should end with a semi-colon. What we are doing is putting the JavaScript inside the quotes of an event. The event is onMouseOver. The alert needs a message and the message inside parenthesis and enclosed in single quotes. If you have quotes within quotes the inner quotes must be single to differentiate. The alert() function puts the message in the () inside the message box. Note that all functions in JavaScript have the form functionName() where sometimes the parenthesis contain data and sometimes they are empty. We will see more of this in later examples. Note one last thing that has nothing to do with JavaScript, because I wanted to Mouse over here! to be large and aligned to the right, I used the paragraph to align to the right and the font to change the font. These are not needed for the JavaScript.<BR> On the next example, I am using both onMouseOver and onMouseOut. I went into PhotoEditor and did a invert with the CISa.gif image and saved it as CISb.gif. Then I can have one image show when the mouse rolls over the image and a second image show when the mouse rolls out.<BR> When I work with an image, I need to be aware of the fact that frequently browers will not let the developer put events inside image tags. So what you have to do is set up the HREF equal to # and put the events inside that and then set up the image source with name as shown above. When the image is firstloaded it will show the image in IMG SRC which in this case is CISa.gif. When the mouse goes over that same image is shown. When the mouse goes out a different image is shown (in this case the inverted image). The dots in document.CISimage.src have special meaning to JavaScript. It will go to the last dot and work backward in the interpretation. So this essentially reads as change the src of CISimage which is in the document. This follows a document object model hierarchy (DOM) which can be referenced in many tutorials on JavaScript.<BR> To make things more efficient you can preload the images. I will illustrate a preload in another example.<BR> One other thing to note - because single and double quotes have special meanings, you cannot use them in the ordinary way in your text. If you want to use the quotes in your text you do it with Jane's where the tells JavaScript to use the single quote instead of interpreting it.
  • 7. <HTML> <HEAD> <TITLE>More events in JavaScript</TITLE> <SCRIPT language="JavaScript"> var CISa_image = new Image(); CISa_image.src = "CISa.gif"; var CISb_image = new Image(); CISb_image.src = "CISb.gif"; </SCRIPT> The word var is optional - however if used it should be lower case. When I write this program with VAR I get an error in explorer about missing ; which essentially means their is a problem with the code. </HEAD> <BODY> The code above preloads two images.<BR> <A HREF="#" onMouseOver="CISimage.src='CISa.gif';" onMouseOut="CISimage.src='CISb.gif';"> <IMG SRC="CISb.gif" NAME="CISimage" BORDER = 0></A> </BODY> </HTML> CISaCISb1.htmlCISaCISb1.html Load the images. The variable name where they are put are CISa_image and CISb_image. This time the CISb.gif is loaded when the form is shown. In this example I am simply giving the image name.
  • 8.
  • 9. <HTML> <HEAD> <TITLE>Java rotate</TITLE> <SCRIPT> originalz = new Image; originalz.src="house.jpg"; flipz = new Image; flipz.src = "houseusd.jpg"; </SCRIPT> </HEAD> <BODY bgcolor=beige> <DIV ALIGN=CENTER> <H1>Here is an image to roll the mouse over</H1> <H3>Rolling the mouse over and out are called events.</H3> <A HREF="javamouse.html" onMouseOver="document.myhouse.src = flipz.src" onMouseOut="document.myhouse.src = originalz.src"> <IMG SRC="house.jpg" NAME="myhouse"></A> </DIV> </BODY> </HTML> javamouse.htmljavamouse.html This code establishes a new Image called originalz and then specifies the source for this image as house.jpg. It then establishes another new image called flipz and then specifies that the source for this image is houseusd.jpg. The events are associated with the A HREF which refers to this page. The events say take the current document or window and then the name associated with the image and make the source the sources that were specified in the <HEAD>. This means the original image shown is house.jpg Document refers to the object of the window that is being worked with. Note I used the defined image name and not the .jpg name.
  • 10. <HTML> <HEAD> <TITLE>Java rotate</TITLE> <SCRIPT language = "JavaScript"> <!--hide from browser that do not support var originalz = new Image; originalz.src="house.jpg"; var flipz = new Image; flipz.src = "houseusd.jpg"; // end of the hide --> </SCRIPT> </HEAD> <BODY bgcolor=beige> <DIV ALIGN=CENTER> <H1>Here is an image to roll the mouse over</H1> <H3>Rolling the mouse over and out are called events.</H3> <A HREF="javamouse.html" onMouseOver="document.myhouse.src = flipz.src;" onMouseOut="document.myhouse.src = originalz.src;"> <IMG SRC="house.jpg" NAME="myhouse"></A> </DIV> Here are a few comments on the program. <UL> <LI>I did not include langauge = "JavaScript" in the SCRIPT of the original program because it is not required. It is a good thing to do because other languages can be used for scripting, such as VB. <LI>This code includes the Hide me if the browser does not support JavaScript code. <LI>var is not required so I did not use it in the previous example. <LI>the semi-colons are not required after the mouse over and out and I did not use them in the previous example </BODY> </HTML>
  • 11.
  • 12. <HTML> <HEAD> <TITLE>Events in Java</TITLE> </HEAD> <BODY bgcolor=aqua> <H3>Events are a different type of Java code because they are built directly into the HTML code. They aren't scripts because their design was to be embedded in the HTML. First I am going to illustrate mouse over/out events.</H3> <P ALIGN=CENTER> <A HREF="tryevent1.html" onMouseOver="alert('Testing events...')">ALERT MOUSE TEST!</A> <BR><BR> <A HREF="tryevent1.html" onMouseOver="document.bgColor='beige'">CHANGE BACKGROUND TO BEIGE!</A> <BR><BR> <A HREF="tryevent1.html" onMouseOver="document.bgColor='aqua'">CHANGE BACKGROUND TO AQUA!</A> <BR><BR> <A HREF="tryevent1.html" onMouseOver="document.bgColor='pink'" onMouseOut="document.bgColor='green'">CHANGE BACKGROUND!</A> <BR><BR> <A HREF="tryevent1.html" onMouseOver="window.status='Testing roll over'; return true" onMouseOut="window.status='Testing roll out'; return true">WINDOW STATUS TRUE TEST!</A> <BR><BR> <A HREF="tryevent1.html" onMouseOver="window.status='Testing roll over'" onMouseOut="window.status='Testing roll out'">WINDOW STATUS TEST!</A> <BR><BR> Note: The return true clause allows the default in the window status to be over ridden. </P> </BODY> </HTML> tryevent1.htmltryevent1.html Different things are happening as a result of the onMouseOver event. In the first example, a popup alert window comes up. In the second the background changes to beige.
  • 13. <A HREF="tryevent1.html" onMouseOver="alert('Testing events...')">ALERT MOUSE TEST!</A> This slide shows the result of moving the mouse over the ALERT MOUSE TEST. The code behind this line is shown below.
  • 14. <A HREF="tryevent1.html" onMouseOver="document.bgColor='beige'">CHANGE BACKGROUND TO BEIGE!</A> This shows the results of running the mouse over CHANGE BACKGROUND TO BEIGE! The code is shown below. Note that “document.bgcolor=‘beige’” is enclosed in double quotes and the word ‘beige’ is enclosed in single quotes because it is embedded in double quotes and trying to use double quotes would confuse the structure of the command.
  • 15. <A HREF="tryevent1.html" onMouseOver="window.status='Testing roll over'; return true" onMouseOut="window.status='Testing roll out'; return true">WINDOW STATUS TRUE TEST!</A>
  • 16. <A HREF="tryevent1.html" onMouseOver="window.status='Testing roll over'; return true" onMouseOut="window.status='Testing roll out'; return true">WINDOW STATUS TRUE TEST!</A>
  • 17. <A HREF="tryevent1.html" onMouseOver="window.status='Testing roll over'" onMouseOut="window.status='Testing roll out'">WINDOW STATUS TEST!</A>
  • 19. <HTML> <HEAD> <TITLE>Events in Java</TITLE> </HEAD> <BODY bgcolor=pink onLoad="alert('WELCOME!')"> <H3>This example illustrates the on click event.</H3> <P ALIGN=CENTER> <A HREF="tryevent2.html" onClick="alert('Testing events...')">ALERT ON CLICK TEST!</A> <BR><BR> </P> <H3>Using onFocus, when you click on the box in the form, the window will display the activity to be done.</H3> <H3>Using onChange tells when the data has been changed.</H3> <FORM NAME="crsform"> Course information: <INPUT TYPE="text" SIZE=5 NAME="crscode" onFocus="window.status='Enter course code'"> <INPUT TYPE="text" SIZE=25 NAME="crsname" onFocus="window.status='Enter course name'"; onChange="alert('The data has been changed')";> <BR><BR> <P>MAJOR:<BR> <INPUT TYPE="RADIO" NAME="major" VALUE="CI">Computer Information Systems<BR> <INPUT TYPE="RADIO" NAME="major" VALUE="BU">Business Administration<BR> <INPUT TYPE="RADIO" NAME="major" VALUE="other">Other major<BR> <H3>The onBlur means that you have lost focus on an answer.</H3> <INPUT TYPE="text" SIZE=25 NAME="crsinst" onFocus="window.status='Enter instructor name'"; onBlur="alert('Did you enter instructor name?')";> <P>Comments:<BR> <TEXTAREA ROWS="6" COLS="40" NAME="Comments"></TEXTAREA> <P> <INPUT TYPE="RESET" VALUE="Clear"> <P> <INPUT TYPE="BUTTON" VALUE="Back" onClick="history.go(-1)"> <INPUT TYPE="BUTTON" VALUE="Forward" onClick="history.go(1)"> </FORM> </BODY> </HTML> tryevent2.htmltryevent2.html
  • 20. <INPUT TYPE="text" SIZE=5 NAME="crscode" onFocus="window.status='Enter course code'">
  • 21. <INPUT TYPE="text" SIZE=25 NAME="crsname" onFocus="window.status='Enter course name'"; onChange="alert('The data has been changed')";>
  • 22. <INPUT TYPE="text" SIZE=25 NAME="crsinst" onFocus="window.status='Enter instructor name'"; onBlur="alert('Did you enter instructor name?')";>
  • 23. <INPUT TYPE="BUTTON" VALUE="Back" onClick="history.go(-1)"> <INPUT TYPE="BUTTON" VALUE="Forward" onClick="history.go(1)">
  • 24.
  • 25. <HTML> <HEAD> <TITLE>More events</TITLE> <SCRIPT language="JavaScript"> var mycolor; var myfont; </SCRIPT> </HEAD> <BODY> <H2>This shows some uses of the onClick event</H2> <IMG SRC="CISa.gif" NAME="originalz"><BR> <A HREF = "#" onClick="window.document.bgColor='beige'";>Make background beige</A><BR> <A HREF = "#" onClick="window.document.fgColor='blue'";>Make font blue</A><BR> <A HREF="#" onClick="mycolor=prompt('Enter your choice of background color',''); window.document.bgColor=mycolor;">Change the background color</A><BR> <A HREF="#" onClick="myfont=prompt('Enter your choice of font color',''); window.document.fgColor=myfont;">Change the font color</A><BR> <A HREF="#" onClick="document.originalz.src='CISb.gif';">Click here to change the top image!</A><BR> <A HREF="#" onClick="document.originalz.src='CISa.gif'; return false;">Click here to change the top image back!</A><BR> onClick.htmlonClick.html The prompt calls for title, data for the input box. In the first case, I want nothing in the input box. In the second case I am using a default of pink. This is shown on the next page.
  • 26. Note: Return false is another way to tell the browser not to follow the link given.<BR> The Prompt puts up a box where the user can enter input. Note that in the prompt I have some words that will become the title, then I entered a comma and two quotes together. The two quotes together make the box where I want the user to enter information blank. If I wanted to put a default in the user entry line I could put in between the quotes.<BR> <A HREF="#" onClick="mycolor=prompt('Enter your choice of background color','pink'); window.document.bgColor=mycolor;">Change the background color</A><BR> Note also that there are two things that I want to do on the click event, one is to get the user to pick a color or in this case, go with the default. The other is to use that color to change the background. The double quotes are around both of these. </BODY> </HTML> onClick.htmlonClick.html
  • 27.
  • 28. <HTML> <HEAD> <TITLE>Javascript font experiment</TITLE> </HEAD> <BODY BGCOLOR=beige> This is an experiment with Javascript and font useage. Note that in javascript terms, the document is an object and the write statement that I am going to include below is a method or in other words an action that is executed on the document. When I do the write below, color and the size are being done to the document at a particular time and this is an instance. Objects can also have properties related to them as shown in the example after dealing with fonts. <BR><BR> <SCRIPT LANGUAGE="javascript"> document.write("<FONT COLOR='GREEN' SIZE=150%>This is green font</FONT>") </SCRIPT> <BR><BR> Now I am going to try this without the double quotes around the whole. You can see that this doesn't work. Essentially the material inside the double quotes will be written to the screen and the HTML code that is included will be executed. Notice that the attempt to get red font below does not work because the double quotes around FONT are missing. <BR><BR> <SCRIPT LANGUAGE="javascript"> document.write(<FONT COLOR="RED" SIZE=150%>This is red font</FONT>) </SCRIPT> Note also since I am using double quotes outside. I need to use single quotes or no quotes inside for the color. <BR><BR> <SCRIPT LANGUAGE="javascript"> document.write("<FONT COLOR=BLUE SIZE=150%>This is blue font</FONT>") </SCRIPT> Font1.htmlFont1.html

Editor's Notes

  1. In this presentation, we will focus on events. The next presentation will cover more of the actual scripting.
  2. Please read some notes on JavaScript. For today, focus on some of the rules involved and on the use of events. Be sure to read about the concepts of objects, methods, objects and events to help you understand the code.
  3. This is an example of mouse over using text and using an image box.
  4. This shows the actual code using the onMouseOver and onMouseOut.
  5. This shows some explanatory notes that are included in the code.
  6. This shows the results of the next page, CISaCISb1.html.
  7. This shows the code with the preload of the images done in JavaScript in the header. Note that with things other than events, JavaScript is enclosed in the SCRIPT shown. It is better to include the clause language = &amp;quot;JavaScript&amp;quot; since ther are other scripting languages. In the previous example instead of CISimage I used document.CISimage. I could also have used window.document.CISimage.
  8. This is the program called javamouse.html. Rolling the mouse over the picture causes it to appear up side down. This is because there are two images. In a graphics package I saved the image, then rotated it 180 degrees and saved it again under a different name.
  9. In the SCRIPT in &amp;lt;HEAD&amp;gt; I establish the two images and name them originalz and flips. Establishing the images in the &amp;lt;HEAD&amp;gt; means that they will be loaded initially and there will not be a delay in the mouse over and mouse out events. Please read an explanation of this click event in one of the many tutorials and fact sheets available on the Web. The explanation here needs to be elaborated on. Note that in this example, I used the name defined in the script for the image instead of the actual .jpg name. In previous examples I used the actual image name enclosed in quotes.
  10. This version is a little more &amp;quot;professionally done&amp;quot;.
  11. This is try event one. It experiments with other uses of the mouse over and mouse off. The code is on the next page. I got this code by opening source in Explorer 5.0 which shows the JavaScript.
  12. Again we are referring to document as the object and in this case bgColor is a property of the document object. Note that in JavaScript the syntax is: Event=&amp;quot;document.property or method&amp;quot; If you need quotes within the quotes, the inner quotes are done with single quotes. In the case of alert we are talking about a different object - a popup alert window that comes up and in the case of window.status we are talking about the object window and the status of that window.
  13. This slide shows the alert which brings up the alert popup window which displays the message inside the parenthesis.
  14. Read about the use of quotes in JavaScript in one of the tutorials.
  15. Note the Testing roll over in the window status. return true &amp;quot;locks&amp;quot; the message into the status line so it won&amp;apos;t be replaced by the default URL.
  16. Compare this to the next set which does not have the return true.
  17. Without return true, the default URL appears.
  18. In this example, the BODY statement has an onLoad event which displays the alert window when the page is opened.
  19. The code for tryevent2.html.
  20. This causes Enter course code to show on the status line when the focus is on the first box after Course information.
  21. When the course name got the focus, the message appeared on the status line. When I left the course name (NAME=&amp;quot;crsnmae&amp;quot;) then the alert window appeared.
  22. When I left the instructor box (NAME=&amp;quot;crsinst&amp;quot;) the onBlur was activated and the alert popup message appeared.
  23. history.go(-1) moves back one screen history.go(1) moves forward one screen Different numbers can be used to control where you go.
  24. This shows a page with a variety of onClick options. You can change background color, default font color, or the image and you can get user input on the colors to use.
  25. This shows the onClick code. Note that the prompt asks for user input. Note that bgColor is background color and fgColor is the default font color - I assume fg means foreground color.
  26. As mentioned on the previous page. This prompt will ask for a choice of color and give the default of pink.
  27. This shows font1.html. Note that font2.html is cleaned up a little and it is missing the purposeful error on this slide. You should look at the code for both.
  28. This is illustrating the use of the document.write() with a variety of different options. Please look at font1.html and font2.html.