JSB6RefBooklet.pdf

(317 KB) Pobierz
AppA.ai
JavaScript and Browser Objects
Quick Reference
JavaScript Bible, 6th Edition
Danny Goodman
Appendix A
©2007 Danny Goodman (dannyg.com). All Rights Reserved.
354937689.004.png
2
JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved.
JavaScript and Browser Objects Quick Reference
String
28
Date
30
Control Statements
32
constructor
length
prototype
anchor(" anchorName ")
big()
blink()
bold()
charAt( index )
charCodeAt([i])
concat( string2 )
fixed()
fontcolor(# rrggbb )
fontsize( 1to7 )
fromCharCode( n1 ...) *
indexOf(" str " [,i])
italics()
lastIndexOf(" str " [,i])
link( url )
localeCompare()
match( regexp )
replace( regexp , str )
search( regexp )
slice(i,j)
small()
split( char )
strike()
sub()
substr( start , length )
substring( intA , intB )
sup()
toLocaleLowerCase()
toLocaleUpperCase()
toLowerCase()
toString()
toUpperCase()
valueOf()
constructor
prototype
getFullYear()
getYear()
getMonth()
getDate()
getDay()
getHours()
getMinutes()
getSeconds()
getTime()
getMilliseconds()
getUTCFullYear()
getUTCMonth()
getUTCDate()
getUTCDay()
getUTCHours()
getUTCMinutes()
getUTCSeconds()
getUTCMilliseconds()
parse(" dateString ") *
setYear( val )
setFullYear( val )
setMonth( val )
setDate( val )
setDay( val )
setHours( val )
setMinutes( val )
setSeconds( val )
setMilliseconds( val )
setTime( val )
setUTCFullYear( val )
setUTCMonth( val )
setUTCDate( val )
setUTCDay( val )
setUTCHours( val )
setUTCMinutes( val )
setUTCSeconds( val )
setUTCMilliseconds( val )
getTimezoneOffset()
toDateString()
toGMTString()
toLocaleDateString()
toLocaleString()
toLocaleTimeString()
toString()
toTimeString()
toUTCString()
UTC( dateValues ) *
if ( condition ) {
statementsIfTrue
}
if ( condition ) {
statementsIfTrue
} else {
statementsIfFalse
}
result = condition ? expr1 : expr2
for ([ init expr ]; [ condition ]; [ update expr ]) {
statements
}
for ( var in object ) {
statements
}
for each ([var] varName in objectRef ) {
statements
} M1.8.1
with ( objRef ) {
statements
}
do {
statements
} while ( condition )
yield value M1.8.1
* Method of the static String object.
while ( condition ) {
statements
}
Regular Expressions
42
global
ignoreCase
input
lastIndex
multiline
lastMatch
lastParen
leftContext
prototype
rightContext
source
$1...$9
compile( regexp )
exec(" string ")*
test(" string ")
str.match( regexp )
str.replace( regexp ," string ")
str.search( regexp )
str.split( regexp [, limit ])
return [ value ]
switch ( expression ) {
case labelN :
statements
[break]
...
[default :
statements ]
}
* Method of the static Date object.
label :
continue [ label ]
break [ label ]
* Returns array with properties: index, input, [0],...[n].
Math *
29
Array
31
E
LN2
LN10
LOG2E
LOG10E
PI
SQRT1_2
SQRT2
abs( val )
acos( val )
asin( val )
atan( val )
atan2( val1 , val2 )
ceil( val )
cos( val )
exp( val )
floor( val )
log( val )
max( val1 , val2 )
min( val1 , val2 )
pow( val1 , power )
random()
round( val )
sin( val )
sqrt( val )
tan( val )
try {
statements to test
}
catch ( errorInfo ) {
statements if exception occurs in try block
}
[finally {
statements to run, exception or not
}]
constructor
length
prototype
concat( array2 )
every( func [, thisObj ]) M1.8
filter( func [, thisObj ]) M1.8
forEach( func [, thisObj ]) M1.8
indexOf( func [, thisObj ]) M1.8
join(" char ")
lastIndexOf( func [, thisObj ]) M1.8
map( func [, thisObj ]) M1.8
pop()
push()
reverse()
shift()
slice(i,[j])
some( func [, thisObj ]) M1.8
sort( compareFunc )
splice(i,j[, items ])
toLocaleString()
toString()
unshift()
throw value
Number
29
constructor
MAX_VALUE
MIN_VALUE
NaN
NEGATIVE_INFINITY
POSITIVE_INFINITY
prototype
toExponential(n)
toFixed(n)
toLocaleString()
toString([ radix ])
toPrecision(n)
valueOf()
* All properties and methods are of the static Math object.
Error
32
Function
34
prototype
constructor
description E
fileName E
lineNumber
message
name
number E
toString()
arguments
caller
constructor
length
prototype
apply( this , argsArray )
call( this [, arg1 [,... argN ]])
toString()
valueOf()
Boolean
29
constructor
prototype
toString()
valueOf()
354937689.005.png
3
JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved.
JavaScript and Browser Objects Quick Reference
Globals
35
Appendix A
JavaScript Bible, 6th Edition
by Danny Goodman
Functions
atob() M
btoa() M
decodeURI(" encodedURI ")
decodeURIComponent(" encComp ")
encodeURI(" URIString ")
encodeURIComponent(" compString ")
escape(" string " [,1])
eval(" string ")
isFinite( number )
isNaN( expression )
isXMLName(" string ") M1.8.1
Number(" string ")
parseFloat(" string ")
parseInt("string" [, radix ])
toString([ radix ])
unescape(" string ")
unwatch( prop )
watch( prop , handler )
How to Use This Quick Reference
This guide contains quick reference info for the
core JavaScript language and browser object
models starting with IE 5.5, Mozilla, and Safari.
Each term is supported by all baseline browsers unless
noted with a superscript symbol indicating browser brand
and version:
E—Internet Explorer M—Mozilla S—Safari
For example, M1.4 means the term is supported only
by Mozilla 1.4 or later; E means the terms is supported
only by Internet Explorer.
Statements
// /*...*/
const
var
Numbers in the upper right corners of object
squares are chapter numbers in which the object
is covered in detail.
Operators
33
frameset
16
window
16
Comparison
==
Equals
border
borderColor E
cols
frameBorder E
frameSpacing E
rows
(None)
onload
appCore M
clientInformation ES1.2
clipboardData E
closed
Components[] M
content M
controllers[] M
crypto M
defaultStatus
dialogArguments E
dialogHeight E
dialogLeft E
dialogTop E
dialogWidth E
directories M
document
event ES
external E
frameElement EMS1.2
frames[]
fullScreen M1.4
history
innerHeight MS
innerWidth MS
length
location
locationbar M
menubar M
name
navigator
netscape M
offscreenBuffering ES1.2
opener
outerHeight MS
outerWidth MS
pageXOffset MS
pageYOffset MS
parent
personalbar M
pkcs11 M
prompter M
returnValue E
screen
screenLeft ES1.2
screenTop ES1.2
screenX MS1.2
screenY MS1.2
scrollbars M
scrollMaxX M1.4
scrollMaxY M1.4
scrollX MS
scrollY MS
self
sidebar M
status
statusbar M
toolbar M
top
window
addEventListener(” evt , func , capt ) MS
alert(” msg ”)
attachEvent(” evt , func ) E
back() M
blur()
clearInterval(ID)
clearTimeout(ID)
close()
confirm(” msg ”)
createPopup() E
detachEvent(” evt , func ) E
dispatchEvent() MS
dump(” msg ”) M1.4
execScript(” exprList ”[, lang ]) E
find([” str ”[, case [, up ]]) M
fireEvent(” evt ”[, evtObj ]) E
focus()
forward() M
geckoActiveXObject(ID) M1.4
getComputedStyle( node , “”) M
getSelection() MS
home() M
moveBy( Δ x, Δ y)
moveTo(x, y)
navigate(” url ”) E
open(” url , “ name ”[, specs ])
openDialog(” url , “ name ”[, specs ]) M
print()
prompt(” msg , ” reply ”)
removeEventListener(” evt , func , capt ) MS
resizeBy(
onabort M
onafterprint E
onbeforeprint E
onbeforeunload E
onblur
onclick
onclose
onerror
onfocus
onhelp E
onkeydown
onkeypress
onkeyup
onload
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
onmove
onreset
onresize EM
onscroll EMS1.3
onunload
===
Strictly equals
!=
Does not equal
!==
Strictly does not equal
>
Is greater than
>=
Is greater than or equal to
<
Is less than
<=
Is less than or equal to
iframe 16
frame
16
Arithmetic
+
Plus (and string concat.)
align
allowTransparency E
contentDocument MS
contentWindow EM
frameBorder E
frameSpacing E
height
hspace E
longDesc
marginHeight
marginWidth
name
noResize
scrolling
src
vspace E
width
allowTransparency E
borderColor E
contentDocument MS
contentWindow EM
frameBorder
height E
longDesc
marginHeight
marginWidth
name
noResize
scrolling
src
width E
-
Minus
*
Multiply
/
Divide
%
Modulo
++
Increment
--
Decrement
- val
Negation
Assignment
=
Equals
+=
Add by value
-=
Subtract by value
*=
Multiply by value
/=
Divide by value
%=
Modulo by value
<<=
Left shift by value
>>=
Right shift by value
>>>=
Zero fill by value
popup E
16
&=
Bitwise AND by value
y)
resizeTo( width , height )
scroll()
scrollBy(
x,
Δ
|=
Bitwise OR by value
document
isOpen
hide()
show()
^=
Bitwise XOR by value
Boolean
&&
y)
scrollByLines(n) M
scrollByPages(n) M
scrollTo(x, y)
setInterval( func , msecs [, args ])
setTimeout( func , msecs [, args ])
showHelp(” url ”) E
showModalDialog(” url ”[, args ][, features ]) ES2.01
showModelessDialog(” url ”[, args ][, features ]) E
sizeToContent() M
stop() M
x,
Δ
AND
||
OR
!
NOT
Bitwise
&
Bitwise AND
|
Bitwise OR
location
^
Bitwise XOR
17
~
Bitwise NOT
assign(" url ")
reload([ unconditional ])
replace(” url ”)
<<
Left shift
hash
host
hostname
href
pathname
port
protocol
search
>>
Right shift
>>>
Zero fill right shift
Miscellaneous
, Series delimiter
delete Property destroyer
in Item in object
instanceof Instance of
new
Object creator
history
17
this
Object self-reference
typeof
Value type
current M(signed)
length
next M(signed)
previous M(signed)
back()
forward()
go( int | " url ")
void
Return no value
Δ
Δ
354937689.006.png
4
JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved.
JavaScript and Browser Objects Quick Reference
document
18
All HTML Element Objects
15
activeElement E
alinkColor
anchors[]
applets[]
baseURI M
bgColor
body
charset E
characterSet M
compatMode EM
contentType M
cookie
defaultCharset E
defaultView M
designMode EM
doctype M
documentElement
documentURI M1.7
domain
embeds[]
expando E
fgColor
fileCreatedDate E
fileModifiedDate E
fileSize E
forms[]
frames[]
height MS
images[]
implementation E6MS
inputEncoding M1.8
lastModified
linkColor
links[]
location
media E
mimeType E
nameProp E6
namespaces[]
parentWindow E
plugins[]
protocol E
referrer
scripts[] E
security E
selection E
strictErrorChecking M1.8
styleSheets[]
title
URL
URLUnencoded E
vlinkColor
width MS
xmlEncoding M1.8
xmlStandalone M1.8
xmlVersion M1.8
clear()
close()
createAttribute(” name ”) E6MS
createCDATASection(” data ”) M
createComment(” text ”) E6MS
createDocumentFragment() E6MS
createElement(” tagname ”)
createElementNS(” uri , “ tagname )
createEvent(” evtType ”) MS
createEventObject([ evtObj ]) E
createNSResolver( nodeResolver ) M
createRange() M
createStyleSheet([” url ”[, index ]]) E
createTextNode(” text ”)
createTreeWalker( root , what , filterfunc , exp ) M1.4
elementFromPoint(x, y) E
evaluate(” expr , node , resolver , type , result ) M
execCommand(” cmd ”[, UI ][, param ]) EM1.3S1.3
getElementById(” ID ”)
getElementsByName(” name ”)
importNode( node , deep ) M
open([” mimetype ”][, “ replace ”])
queryCommandEnabled(” commandName ”) EM1.3
queryCommandIndterm(” commandName ”)
queryCommandState(” commandName ”)
queryCommandSupported(” commandName ”)
queryCommandText(” commandName ”)
queryCommandValue(” commandName ”)
recalc([ all ]) E
write(” string ”)
writeln(” string ”)
onselectionchange E
onstop E
accessKey
all[] E
attributes[]
baseURI M
behaviorUrns[] E
canHaveChildren E
canHaveHTML E
childNodes[]
children ES1.2
cite E6MS
className
clientHeight
clientLeft E
clientTop E
clientWidth
contentEditable ES1.2
currentStyle E
dateTime E6M
dataFld E
dataFormatAs E
dataSrc E
dir
disabled
document ES1.2
filters[] E
firstChild
height
hideFocus E
id
innerHTML
innerText ES
isContentEditable ES1.2
isDisabled E
isMultiLine E
isTextEdit E
lang
language E
lastChild
length
localName MS
namespaceURI MS
nextSibling
nodeName
nodeType
nodeValue
offsetHeight
offsetLeft
offsetParent
offsetTop
offsetWidth
outerHTML ES1.3
outerText ES1.3
ownerDocument
parentElement ES1.2
parentNode
parentTextEdit E
prefix MS
previousSibling
readyState E
recordNumber E
runtimeStyle E
scopeName E
scrollHeight
scrollLeft
scrollTop
scrollWidth
sourceIndex E
style
tabIndex
tagName
tagUrn E
textContent M1.7
title
uniqueID E
unselectable E
width
addBehavior(” url ”) E
addEventListener(” evt , func , capt ) MS
appendChild( node )
applyElement( elem [, type ]) E
attachEvent(” evt , func ) E
blur()
clearAttributes() E
click()
cloneNode( deep )
compareDocumentPosition( node ) M1.4
componentFromPoint(x, y) E
contains( elem ) E
createControlRange() E
detachEvent(” evt , func ) E
dispatchEvent( evtObj ) MS
doScroll(” action ”) E
dragDrop() E
fireEvent(” evtType ”[, evtObj ]) E
focus()
getAdjacentText(” where ”) E
getAttribute(” name ”[, case ])
getAttributeNode(” name ”) E6MS
getAttributeNodeNS(” uri , “ name ”) M
getAttributeNS(” uri , “ name ”) M
getBoundingClientRect() E
getClientRects() E
getElementsByTagName(” tagname ”)
getElementsByTagNameNS(” uri , “ name ”) M
getExpression(” attrName ”) E
getFeature(” feature , “ version ”) M1.7.2
getUserData(” key ”) M1.7.2
hasAttribute(” attrName ”) MS
hasAttributeNS(” uri , “ name ”) M
hasAttributes() MS
hasChildNodes()
insertAdjacentElement(” where , obj ) E
insertAdjacentHTML(” where , “ HTML ”) E
insertAdjacentText(” where” , “ text ”) E
insertBefore( newNode , refNode )
isDefaultNamespace(” uri ”) M1.7.2
isEqualNode( node ) M1.7.2
isSameNode( node ) M1.7.2
isSupported(” feature , “ version ”) MS
item( index )
lookupNamespaceURI(” prefix ”) M1.7.2
lookupPrefix(” uri ”) M1.7.2
mergeAttributes( srcObj ) E
normalize()
releaseCapture() E
removeAttribute(” attrName ”[, case ])
removeAttributeNode( attrNode ) E6MS
removeAttributeNS(” uri , “ name ”) M
removeBehavior( ID ) E
removeChild(node)
removeEventListener(” evt , func , capt ) MS
removeExpression(” propName ”) E
removeNode( childrenFlag ) E
replaceAdjacentText(” where , “ text ”) E
replaceChild( newNode , oldNode )
replaceNode( newNode ) E
scrollIntoView( topFlag ) EMS2.02
setActive() E
setAttribute(” name , “ value ”[, case ])
setAttributeNode( attrNode ) E6MS
setAttributeNodeNS(” uri , “ name ”) M
setAttributeNS(” uri , “ name , “ value ”) M
setCapture( containerFlag ) E
setExpression(” propName , “ expr ”) E
setUserData(” key , data , handler ) M1.7.2
swapNode( nodeRef ) E
tags(” tagName ”) E
toString()
urns(” behaviorURN ”) E
onactivate E
onafterupdate E
onbeforecopy ES1.3
onbeforecut ES1.3
onbeforedeactivate E
onbeforeeditfocus E
onbeforepaste ES1.3
onbeforeupdate E
onblur
oncellchange E
onclick
oncontextmenu EM
oncontrolselect E
oncopy ES1.3
oncut ES1.3
ondataavailable E
ondatasetchanged E
ondatasetcomplete E
ondblclick
ondeactivate E
ondrag ES1.3
ondragend ES1.3
ondragenter ES1.3
ondragleave ES1.3
ondragover ES1.3
ondragstart ES1.3
ondrop ES1.3
onerrorupdate E
onfilterchange E
onfocus
onfocusin E
onfocusout E
onhelp E
onkeydown
onkeypress
onkeyup
onlayoutcomplete E
onlosecapture E
onmousedown
onmouseenter E
onmouseleave E
onmousemove
onmouseout
onmouseover
onmouseup
onmousewheel E
onmove E
onmoveend E
onmovestart E
onpaste ES1.3
onpropertychange E
onreadystatechange EMS1.2
onresize
onresizeend E
onresizestart E
onrowenter E
onrowexit E
onrowsdelete E
onrowsinserted E
onscroll E
onselectstart ES1.3
link
37
html
37
charset
disabled
href
hreflang E6MS
media
rel
rev
sheet M
styleSheet E
target
type
(None)
onload E
version E6MS
head
37
profile
title
37
text
base
37
href
target
script
37
meta
37
defer
event
htmlFor
src
text
type
charset E
content
httpEquiv
name
url E
354937689.007.png 354937689.001.png
5
JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved.
JavaScript and Browser Objects Quick Reference
body
18
h1...h6
36
Range MS
36
alink
background
bgColor
bgProperties E
bottomMargin E
leftMargin E
link
noWrap E
rightMargin E
scroll E
scrollLeft EM
scrollTop EM
text
topMargin E
vLink
createControlRange() E
createTextRange() E
doScroll(” scrollAction ”) E
onafterprint E
onbeforeprint E
onscroll E
align
collapsed
commonAncestorContainer
endContainer
endOffset
startContainer
startOffset
cloneContents()
cloneRange()
collapse([ start ])
compareBoundaryPoints( type , src)
compareNode( node )
comparePoint( node , offset )
createContextualFragment(" text ")
deleteContents()
detach()
extractContents()
insertNode( node )
intersectsNode( node )
isPointInRange( node , off offset set)
selectNode( node )
selectNodeContents( node )
setEnd( node , offset )
setEndAfter( node )
setEndBefore( node )
setStart( node , offset )
setStartAfter( node )
setStartBefore( node )
surroundContents( node )
toString()
br
36
clear
blockquote, q 36
cite E6MS
font
36
color
face
size
marquee
36
ol
38
hr
36
behavior E
bgColor E
direction EM
height EM
hspace EM
loop E
scrollAmount EM
scrollDelay EM
trueSpeed E
vspace E
width E
start() EM
stop() EM
onbounce E
onfinish E
onstart E
start
type
align
color E
noShade
size
width
ul
38
type
TextRange E
36
li
38
dl, dt, dd
38
boundingHeight
boundingLeft
boundingTop
boundingWidth
htmlText
offsetLeft
offsetTop
text
collapse([ start ])
compareEndPoints(" type ", range )
duplicate()
execCommand(" cmd "[, UI [, val ]])
expand(" unit ")
findText(" str "[, scope , flags ])
getBookmark()
getBoundingClientRect()
getClientRects()
inRange( range )
isEqual( range )
move(" unit "[, count ])
moveEnd(" unit "[, count ])
moveStart(" unit "[, count ])
moveToBookmark(" bookmark ")
moveToElementText( elem )
moveToPoint(x,y)
parentElement()
pasteHTML(" HTMLText ")
queryCommandEnabled(" cmd ")
queryCommandIndeterm(" cmd ")
queryCommandState(" cmd ")
queryCommandSupported(" cmd ")
queryCommandText(" cmd ")
queryCommandValue(" cmd ")
scrollIntoView()
select()
setEndPoint(" type ", range )
type
value
compact
canvas M1.8S1.3
20
img
20
fillStyle
globalAlpha
globalCompositeOperation
lineCap
lineJoin
lineWidth
miterLimit
shadowBlur
shadowColor
shadowOffsetX
shadowOffsetY
strokeStyle
target
arc(x, y, radius , start , end , clockwise )
arcTo( x1 , y1 , x2 , y2 , radius )
bezierCurveTo( cp1x , cp1y , cp2x , cp2y , x, y)
beginPath()
clearRect(x, y, width , height )
clip()
closePath()
createLinearGradient( x1 , y1 , x2 , y2 )
createPattern( img , repetition )
createRadialGradient( x1 , y1 , radius1 , x2 , y2 , radius2 )
drawImage( img , x, y)
drawImage( img , x, y, width , height )
fill()
fillRect(x, y, width , height )
getContext( contextID )
lineTo(x, y)
moveTo(x, y)
quadraticCurveTo( cpx , cpy , x, y)
rect(x, y, width , height )
restore()
rotate( angle )
save()
scale(x, y)
stroke()
strokeRect(x, y, width , height )
translate(x, y)
align
alt
border
complete EM
dynsrc E
fileCreatedDate E
fileModifiedDate E
fileSize E
fileUpdatedDate E
height
href
hspace
isMap
longDesc E6MS
loop E
lowsrc EM
mimeType E6
name
nameProp E
naturalHeight M
naturalWidth M
protocol E
src
start E
useMap
vspace
width
x MS
y MS
(None)
onabort
onerror
onload
a
19
charset E6MS
coords E6MS
hash
host
hostname
href
hreflang E6MS
Methods E
mimeType E
name
nameProp E
pathname
port
protocol
rel
rev
search
shape E6MS
target
type E6MS
urn E
selection
36
anchorNode M
anchorOffset M
focusNode M
focusOffset M
isCollapsed M
rangeCount M
type E
typeDetail E
addRange(range) M
clear() E
collapse(node, offset) M
collapseToEnd() M
collapseToStart() M
containsNode(node, entireFlag) M
createRange() E
deleteFromDocument() M
empty() E
extend(node, offset) M
getRangeAt(rangeIndex) M
removeAllRanges() M
removeRange(range) M
selectAllChildren(elementRef ) M
toString() M
map
20
area
20
areas[]
name
(None)
onscroll E
alt
coords
hash
host
hostname
href
noHref
pathname
port
protocol
search
shape
target
TextRectangle E
36
bottom
left
right
top
354937689.002.png 354937689.003.png
Zgłoś jeśli naruszono regulamin