JavaScript Cheat Sheet

advertisement
The Illinois Institute of Art, Chicago
Object
JavaScript Function "Cheat Sheet"
Function / Property
Parameters
Sample
Use
.alert()
message as string
window.alert("Hello World");
.status()
message as string
window.status("Getting data");
To display and alert box with the
provided message
To temporarily set the value of the
browser's status window
Opens the print dialog box for
printing a web page
Starts a timer that repeatedly calls a
function every X milliseconds
window
.print()
setInterval()
setTimeout()
.open()
.home()
.prompt
window.print();
expression (or function),
milliseconds as integer,
[parameter values as optional
list]
same as SetInterval()
setInterval("myFunction()",100)
setTimeout("MoveDragon()",100)
Starts one-time a timer that calls a
function after delete of X
milliseconds
URL as string, window name window.open("http://www.google.co To open a new browser window
as string, window parameters m","","");
as string
window.home()
To navigate to the user defined
home page
window.prompt("What
is
your
To
display a dialog box that request
message as string, default
name","");
information from the user
value as any
document (child to window)
.body
.fgColor()
.location
a hexademal value or plain
document.fgColor = "red"
color as string
a full or relative URL as a string document.location =
"http://www.google.com";
.anchors[]
.forms[]
.images[]
.links[]
MM335
document.images[1].src =
"image.gif"
document.links[1].src =
"http://www.google.com"
object that hold the HTML <body>
element's content
sets the foreground color (text color)
of the document
Returns the URL of the document,
or redirects the web browser to a
new URL
Returns an array of the anchor
objects in the document
Returns an array of the form objects
(links) in the document
Returns an array of the image
objects (links) in the document
Returns an array of the link objects
(links) in the document
Supported
By:
IE
Y
NN
Y
Y
M
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
Y
M
Y
M
Y
Y
Y
M
Y
Y
Y
Y
Y
M
Instructor: Lindsay D. Grace
The Illinois Institute of Art, Chicago
Object
Function / Property
Parameters
JavaScript Function "Cheat Sheet"
Sample
.scripts[]
.write()
Use
Supported
By:
Y
Returns an array of the script
objects (links) in the document
message as string
N
document.write ("message")
To content to the document object
Y
Y
.clientX
var mouseX = event.clientX
Returns the X coordinate of the
mouse after an event has been fired
Y
Y
.clientY
var mouseY = event.clientY
Returns the Y coordinate of the
mouse after an event has been fired
Y
Y
var strBrowser =
navigator.appName
var strVersion =
navigator.appVersion
Returns the browser name as a
string
Returns the version number of the
browser
Returns the CPU information of the
computer running the browser
Returns the name of the operating
system
Y
Y
Y
M
Y
M
Y
M
Y
M
event
navigator
.appName
.appVersion
.cpuClass
.platform
.userAgent
MM335
if (navigator.platform=="Win32") {
"documen.write("you are using
windows 95/NT computer"); }
navigator.userAgent
Returns complete information about
the browser software as a string
Instructor: Lindsay D. Grace
Download