Hard Reload
To See Menu |
<script
language="JavaScript">
<!--
|
onLoad
onUnLoad |
function
odor_(){
window.status="You really do smell.";
alert("Please don't enter \nthis site if you smell !!")}
|
These functions use both the window object status and the
document object alert methods. |
function
eater_(){
alert("Good !\n We can all breath again.")}
// -->
</script>
|
N
O
T
E |
The \n is an escaped string character used to generate a new line. Similar to an
HTML <br> tag. Others include \" doubleqoute, \' singlequote, \\ backslash \b backspace \f form feed, \r carriage return & \t tab. |
|
|
<body
onLoad="odor_()" onUnLoad="eater_()">
|
That's it onLoad & onUnLoad.
H
I
N
T |
These event handler can be used to execute a number
of functions, like issuing password challenges, greetings, starting/stopping clocks or
timers. If you need to call multiple functions onLoad or onUnLoad, create a function that
calls them all, because these event handlers only handle one argument. |
|
|
|
|
onUnLoad to set a cookie
|
|
|
|
<form name="cook">
<input type="text" name="cname" size="20">
<input type="text" name="cval" size="20">
</form>
|
Both windows use the same form cook. This is not
necessary, only a convenience. |
|
|
<body
onUnLoad="sETit()">
<script language="JavaScript"><!--
function sETit() {
namer = document.cook.cname.value.toString()
valuer = document.cook.cval.value.toString()
SetCookie(namer,valuer,expdate); }// --></script>
|
test4.htm
uses the onUnLoad
event handler to set a cookie via the function sETit().
sETit()
simply collects the form inputs and sets a cookie. The expdate defines the expiration date which
was set to 24 hrs from now.
These functions utilize
Bill
Dortch's 'Cookie Functions'. The script is embedded in test4.htm.
|
<script language="JavaScript"><!--
function gETit() {
namer = document.cook.cname.value
document.cook.cval.value = GetCookie(namer) }
// --></script>
|
This is the script for this page. Type in
the cookie name(the same name you used in test4.htm. gETit() calls the function GetCookie to
retrieve the cookie value.
N
O
T
E |
Cookies
are only accessible by documents in the same directory tree. This document and test4 are both in the directory, JSBook/Events, therefore, the
cookie you set is available to both documents. |
|
|