J S B6 Ref Booklet

1,244 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,244
On SlideShare
0
From Embeds
0
Number of Embeds
26
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

J S B6 Ref Booklet

  1. 1. JavaScript and Browser Objects Quick Reference JavaScript Bible, 6th Edition Danny Goodman Appendix A ©2007 Danny Goodman (dannyg.com). All Rights Reserved.
  2. 2. JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved. 2 JavaScript and Browser Objects Quick Reference String Date Control Statements 28 30 32 constructor anchor(quot;anchorNamequot;) constructor getFullYear() if (condition) { length big() prototype getYear() statementsIfTrue prototype blink() getMonth() } bold() getDate() charAt(index) getDay() if (condition) { charCodeAt([i]) getHours() statementsIfTrue concat(string2) getMinutes() } else { fixed() getSeconds() statementsIfFalse fontcolor(#rrggbb) getTime() } fontsize(1to7) getMilliseconds() fromCharCode(n1...)* getUTCFullYear() result = condition ? expr1 : expr2 indexOf(quot;strquot; [,i]) getUTCMonth() italics() getUTCDate() for ([init expr]; [condition]; [update expr]) { lastIndexOf(quot;strquot; [,i]) getUTCDay() statements link(url) getUTCHours() } localeCompare() getUTCMinutes() match(regexp) getUTCSeconds() for (var in object) { replace(regexp,str) getUTCMilliseconds() statements parse(quot;dateStringquot;)* search(regexp) } slice(i,j) setYear(val) small() setFullYear(val) for each ([var] varName in objectRef) { split(char) setMonth(val) statements }M1.8.1 strike() setDate(val) sub() setDay(val) substr(start,length) setHours(val) with (objRef) { substring(intA, intB) setMinutes(val) statements sup() setSeconds(val) } toLocaleLowerCase() setMilliseconds(val) toLocaleUpperCase() setTime(val) do { toLowerCase() setUTCFullYear(val) statements toString() setUTCMonth(val) } while (condition) toUpperCase() setUTCDate(val) yield valueM1.8.1 valueOf() setUTCDay(val) setUTCHours(val) *Method of the static String object. setUTCMinutes(val) while (condition) { setUTCSeconds(val) statements Regular Expressions setUTCMilliseconds(val) } 42 getTimezoneOffset() global compile(regexp) toDateString() return [value] ignoreCase exec(quot;stringquot;)* toGMTString() input test(quot;stringquot;) toLocaleDateString() switch (expression) { lastIndex str.match(regexp) toLocaleString() case labelN : multiline str.replace(regexp,quot;stringquot;) toLocaleTimeString() statements lastMatch str.search(regexp) toString() [break] lastParen str.split(regexp[,limit]) toTimeString() ... leftContext toUTCString() [default : prototype UTC(dateValues)* statements] rightContext } *Method of the static Date object. source $1...$9 label : continue [label] Math* 29 *Returns array with properties: index, input, [0],...[n]. break [label] E abs(val) try { LN2 acos(val) Array 31 statements to test LN10 asin(val) } LOG2E atan(val) constructor concat(array2) catch (errorInfo) { every(func[, thisObj])M1.8 LOG10E atan2(val1, val2) length statements if exception occurs in try block filter(func[, thisObj])M1.8 PI ceil(val) prototype } forEach(func[, thisObj])M1.8 SQRT1_2 cos(val) [finally { indexOf(func[, thisObj])M1.8 SQRT2 exp(val) statements to run, exception or not floor(val) join(quot;charquot;) }] lastIndexOf(func[, thisObj])M1.8 log(val) map(func[, thisObj])M1.8 max(val1, val2) throw value min(val1, val2) pop() pow(val1, power) push() random() reverse() round(val) shift() sin(val) slice(i,[j]) Number 29 some(func[, thisObj])M1.8 sqrt(val) tan(val) sort(compareFunc) constructor toExponential(n) splice(i,j[,items]) MAX_VALUE toFixed(n) *All properties and methods are of the static Math object. toLocaleString() MIN_VALUE toLocaleString() toString() NaN toString([radix]) unshift() Error NEGATIVE_INFINITY toPrecision(n) 32 POSITIVE_INFINITY valueOf() prototype toString() prototype Function 34 constructor descriptionE arguments apply(this, argsArray) fileNameE caller call(this[,arg1[,...argN]]) Boolean lineNumber 29 constructor toString() message length valueOf() constructor toString() name prototype numberE prototype valueOf()
  3. 3. JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved. 3 JavaScript and Browser Objects Quick Reference Globals Appendix A 35 Functions JavaScript Bible, 6th Edition atob()M btoa()M by Danny Goodman decodeURI(quot;encodedURIquot;) decodeURIComponent(quot;encCompquot;) encodeURI(quot;URIStringquot;) How to Use This Quick Reference encodeURIComponent(quot;compStringquot;) escape(quot;stringquot; [,1]) eval(quot;stringquot;) This guide contains quick reference info for the Each term is supported by all baseline browsers unless isFinite(number) core JavaScript language and browser object noted with a superscript symbol indicating browser brand isNaN(expression) isXMLName(quot;stringquot;)M1.8.1 models starting with IE 5.5, Mozilla, and Safari. and version: Number(quot;stringquot;) E—Internet Explorer M—Mozilla S—Safari parseFloat(quot;stringquot;) Statements Numbers in the upper right corners of object For example, M1.4 means the term is supported only parseInt(quot;stringquot; [,radix]) // /*...*/ squares are chapter numbers in which the object by Mozilla 1.4 or later; E means the terms is supported toString([radix]) const unescape(quot;stringquot;) is covered in detail. only by Internet Explorer. var unwatch(prop) watch(prop, handler) Operators frameset window 33 16 16 border Comparison (None) onload appCoreM addEventListener(”evt” func,capt)MS onabortM , borderColorE == Equals clientInformationES1.2 onafterprintE alert(”msg”) cols === Strictly equals clipboardDataE attachEvent(”evt” func)E onbeforeprintE , frameBorderE != Does not equal back()M onbeforeunloadE closed frameSpacingE !== Strictly does not equal Components[]M blur() onblur rows > Is greater than contentM clearInterval(ID) onclick >= Is greater than or equal to controllers[]M clearTimeout(ID) onclose < Is less than cryptoM close() onerror <= Is less than or equal to frame iframe 16 16 defaultStatus confirm(”msg”) onfocus dialogArgumentsE E onhelpE createPopup() allowTransparencyE Arithmetic align dialogHeightE E detachEvent(”evt” func) , onkeydown allowTransparencyE borderColorE + Plus (and string concat.) dialogLeftE dispatchEvent()MS onkeypress contentDocumentMS contentDocumentMS - Minus dialogTopE dump(”msg”)M1.4 onkeyup contentWindowEM contentWindowEM * Multiply dialogWidthE execScript(”exprList”[, lang])E onload frameBorderE / Divide frameBorder directoriesM find([”str”[, case[, up]])M onmousedown frameSpacingE heightE % Modulo fireEvent(”evt”[, evtObj])E document onmousemove ++ Increment height longDesc eventES focus() onmouseout hspaceE -- Decrement marginHeight externalE forward()M onmouseover -val Negation longDesc marginWidth frameElementEMS1.2 geckoActiveXObject(ID)M1.4 onmouseup marginHeight name M frames[] getComputedStyle(node, “”) onmove Assignment marginWidth noResize fullScreenM1.4 MS getSelection() onreset = Equals name scrolling M onresizeEM history home() += Add by value noResize src moveBy(Δx, Δy) innerHeightMS onscrollEMS1.3 widthE -= Subtract by value scrolling innerWidthMS moveTo(x, y) onunload *= Multiply by value src navigate(”url”)E length vspaceE /= Divide by value location open(”url” “name”[, specs]) , %= Modulo by value width locationbarM openDialog(”url” “name”[, specs])M , <<= Left shift by value menubarM print() >>= Right shift by value name prompt(”msg” ”reply”) , >>>= Zero fill by value popupE removeEventListener(”evt” func,capt)MS navigator , 16 &= Bitwise AND by value resizeBy(Δx, Δy) netscapeM |= Bitwise OR by value document hide() offscreenBufferingES1.2 resizeTo(width, height) ^= Bitwise XOR by value isOpen show() opener scroll() scrollBy(Δx, Δy) outerHeightMS Boolean outerWidthMS scrollByLines(n)M && AND pageXOffsetMS scrollByPages(n)M || OR pageYOffsetMS scrollTo(x, y) ! NOT parent setInterval(func, msecs[, args]) personalbarM setTimeout(func, msecs[, args]) Bitwise pkcs11M showHelp(”url”)E & Bitwise AND prompterM showModalDialog(”url”[, args][, features])ES2.01 | Bitwise OR returnValueE showModelessDialog(”url”[, args][, features])E location 17 ^ Bitwise XOR sizeToContent()M screen ~ Bitwise NOT screenLeftES1.2 stop()M assign(quot;urlquot;) hash << Left shift screenTopES1.2 reload([unconditional]) host >> Right shift screenXMS1.2 replace(”url”) hostname >>> Zero fill right shift screenYMS1.2 href scrollbarsM pathname Miscellaneous scrollMaxXM1.4 port , Series delimiter scrollMaxYM1.4 protocol delete Property destroyer scrollXMS search in Item in object scrollYMS instanceof Instance of self new Object creator history sidebarM 17 this Object self-reference status typeof Value type statusbarM currentM(signed) back() void Return no value toolbarM length forward() nextM(signed) top go(int | quot;urlquot;) previousM(signed) window
  4. 4. JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved. 4 JavaScript and Browser Objects Quick Reference document All HTML Element Objects 18 15 onselectionchangeE activeElementE clear() addBehavior(”url”)E onactivateE accessKey onstopE close() all[]E addEventListener(”evt” func,capt)MS onafterupdateE alinkColor , createAttribute(”name”)E6MS onbeforecopyES1.3 anchors[] attributes[] appendChild(node) createCDATASection(”data”)M baseURIM applyElement(elem[, type])E onbeforecutES1.3 applets[] createComment(”text”)E6MS baseURIM behaviorUrns[]E attachEvent(”evt” func)E onbeforedeactivateE , createDocumentFragment()E6MS canHaveChildrenE onbeforeeditfocusE bgColor blur() createElement(”tagname”) canHaveHTMLE E onbeforepasteES1.3 body clearAttributes() charsetE createElementNS(”uri” “tagname) , onbeforeupdateE childNodes[] click() createEvent(”evtType”)MS characterSetM childrenES1.2 cloneNode(deep) onblur createEventObject([evtObj])E compatModeEM citeE6MS compareDocumentPosition(node)M1.4 oncellchangeE createNSResolver(nodeResolver)M contentTypeM componentFromPoint(x, y)E className onclick createRange()M contains(elem)E oncontextmenuEM cookie clientHeight createStyleSheet([”url”[, index]])E defaultCharsetE clientLeftE createControlRange()E oncontrolselectE defaultViewM createTextNode(”text”) clientTopE detachEvent(”evt” func)E oncopyES1.3 , createTreeWalker(root, what, filterfunc, exp)M1.4 designModeEM dispatchEvent(evtObj)MS oncutES1.3 clientWidth doctypeM elementFromPoint(x, y)E contentEditableES1.2 doScroll(”action”)E ondataavailableE evaluate(”expr” node, resolver, type, result)M , currentStyleE dragDrop()E ondatasetchangedE documentElement execCommand(”cmd”[, UI][, param])EM1.3S1.3 documentURIM1.7 dateTimeE6M fireEvent(”evtType”[, evtObj])E ondatasetcompleteE getElementById(”ID”) dataFldE domain focus() ondblclick getElementsByName(”name”) dataFormatAsE getAdjacentText(”where”)E ondeactivateE embeds[] importNode(node, deep)M expandoE dataSrcE ondragES1.3 getAttribute(”name”[, case]) open([”mimetype”][, “replace”]) getAttributeNode(”name”)E6MS ondragendES1.3 fgColor dir queryCommandEnabled(”commandName”)EM1.3 fileCreatedDateE getAttributeNodeNS(”uri” “name”)M ondragenterES1.3 disabled , fileModifiedDateE queryCommandIndterm(”commandName”) documentES1.2 getAttributeNS(”uri” “name”)M ondragleaveES1.3 , fileSizeE queryCommandState(”commandName”) filters[]E getBoundingClientRect()E ondragoverES1.3 queryCommandSupported(”commandName”) getClientRects()E ondragstartES1.3 forms[] firstChild queryCommandText(”commandName”) ondropES1.3 frames[] height getElementsByTagName(”tagname”) heightMS queryCommandValue(”commandName”) hideFocusE getElementsByTagNameNS(”uri” “name”)M onerrorupdateE , recalc([all])E getExpression(”attrName”)E onfilterchangeE images[] id implementationE6MS write(”string”) getFeature(”feature” “version”)M1.7.2 innerHTML , onfocus inputEncodingM1.8 writeln(”string”) innerTextES getUserData(”key”)M1.7.2 onfocusinE isContentEditableES1.2 hasAttribute(”attrName”)MS onfocusoutE lastModified isDisabledE hasAttributeNS(”uri” “name”)M onhelpE linkColor , isMultiLineE hasAttributes()MS links[] onkeydown isTextEditE location hasChildNodes() onkeypress mediaE insertAdjacentElement(”where” obj)E lang , onkeyup mimeTypeE languageE insertAdjacentHTML(”where” “HTML”)E onlayoutcompleteE , namePropE6 insertAdjacentText(”where”, “text”)E onlosecaptureE lastChild namespaces[] length insertBefore(newNode, refNode) onmousedown parentWindowE localNameMS isDefaultNamespace(”uri”)M1.7.2 onmouseenterE namespaceURIMS isEqualNode(node)M1.7.2 onmouseleaveE plugins[] protocolE isSameNode(node)M1.7.2 nextSibling onmousemove isSupported(”feature” “version”)MS referrer nodeName , onmouseout scripts[]E nodeType item(index) onmouseover securityE lookupNamespaceURI(”prefix”)M1.7.2 nodeValue onmouseup selectionE lookupPrefix(”uri”)M1.7.2 onmousewheelE offsetHeight strictErrorCheckingM1.8 mergeAttributes(srcObj)E onmoveE offsetLeft onmoveendE styleSheets[] offsetParent normalize() releaseCapture()E onmovestartE title offsetTop onpasteES1.3 URL offsetWidth removeAttribute(”attrName”[, case]) URLUnencodedE outerHTMLES1.3 removeAttributeNode(attrNode)E6MS onpropertychangeE outerTextES1.3 removeAttributeNS(”uri” “name”)M onreadystatechangeEMS1.2 vlinkColor , widthMS removeBehavior(ID)E ownerDocument onresize xmlEncodingM1.8 parentElementES1.2 onresizeendE removeChild(node) xmlStandaloneM1.8 removeEventListener(”evt” func,capt)MS onresizestartE parentNode , xmlVersionM1.8 parentTextEditE removeExpression(”propName”)E onrowenterE prefixMS removeNode(childrenFlag)E onrowexitE replaceAdjacentText(”where” “text”)E onrowsdeleteE previousSibling , link html 37 readyStateE onrowsinsertedE 37 replaceChild(newNode, oldNode) recordNumberE replaceNode(newNode)E onscrollE onloadE versionE6MS runtimeStyleE scrollIntoView(topFlag)EMS2.02 onselectstartES1.3 charset (None) scopeNameE setActive()E disabled href scrollHeight setAttribute(”name” “value”[, case]) , head 37 hreflangE6MS setAttributeNode(attrNode)E6MS scrollLeft setAttributeNodeNS(”uri” “name”)M media scrollTop , profile setAttributeNS(”uri” “name” “value”)M rel scrollWidth , , sourceIndexE setCapture(containerFlag)E rev title 37 sheetM setExpression(”propName” “expr”)E style , styleSheetE setUserData(”key” data, handler)M1.7.2 tabIndex , text swapNode(nodeRef)E target tagName tagUrnE tags(”tagName”)E type textContentM1.7 toString() base 37 urns(”behaviorURN”)E title uniqueIDE href unselectableE target width script 37 meta 37 defer event charsetE htmlFor content src httpEquiv text name type urlE
  5. 5. JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved. 5 JavaScript and Browser Objects Quick Reference RangeMS body h1...h6 36 36 18 align collapsed cloneContents() createControlRange()E onafterprintE alink commonAncestorContainer cloneRange() createTextRange()E onbeforeprintE background endContainer collapse([start]) doScroll(”scrollAction”)E onscrollE bgColor br 36 bgPropertiesE endOffset compareBoundaryPoints(type,src) bottomMarginE startContainer compareNode(node) clear leftMarginE startOffset comparePoint(node, offset) createContextualFragment(quot;textquot;) link blockquote, q 36 noWrapE deleteContents() rightMarginE detach() citeE6MS scrollE extractContents() scrollLeftEM insertNode(node) font 36 scrollTopEM intersectsNode(node) isPointInRange(node, offoffsetset) text color topMarginE selectNode(node) face selectNodeContents(node) vLink size setEnd(node,offset) setEndAfter(node) setEndBefore(node) ol marquee hr setStart(node,offset) 36 38 36 setStartAfter(node) start align behaviorE start()EM onbounceE setStartBefore(node) colorE type bgColorE stop()EM onfinishE surroundContents(node) noShade directionEM onstartE toString() size heightEM ul 38 width hspaceEM loopE type TextRangeE 36 scrollAmountEM scrollDelayEM li collapse([start]) boundingHeight 38 trueSpeedE dl, dt, dd 38 compareEndPoints(quot;typequot;,range) boundingLeft vspaceE type duplicate() boundingTop widthE compact value execCommand(quot;cmdquot;[,UI[,val]]) boundingWidth expand(quot;unitquot;) htmlText findText(quot;strquot;[,scope,flags]) offsetLeft img canvasM1.8S1.3 20 20 getBookmark() offsetTop getBoundingClientRect() text onabort align arc(x, y, radius, start, end, clockwise) fillStyle (None) getClientRects() onerror alt arcTo(x1, y1, x2, y2, radius) globalAlpha inRange(range) onload border bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) globalCompositeOperation isEqual(range) completeEM beginPath() lineCap move(quot;unitquot;[,count]) dynsrcE clearRect(x, y, width, height) lineJoin moveEnd(quot;unitquot;[,count]) fileCreatedDateE clip() lineWidth moveStart(quot;unitquot;[,count]) fileModifiedDateE closePath() miterLimit moveToBookmark(quot;bookmarkquot;) fileSizeE createLinearGradient(x1, y1, x2, y2) shadowBlur moveToElementText(elem) fileUpdatedDateE createPattern(img, repetition) shadowColor moveToPoint(x,y) height createRadialGradient(x1, y1, radius1, x2, y2, radius2) shadowOffsetX parentElement() href drawImage(img, x, y) shadowOffsetY pasteHTML(quot;HTMLTextquot;) hspace drawImage(img, x, y, width, height) strokeStyle queryCommandEnabled(quot;cmdquot;) isMap fill() target queryCommandIndeterm(quot;cmdquot;) longDescE6MS fillRect(x, y, width, height) queryCommandState(quot;cmdquot;) loopE getContext(contextID) queryCommandSupported(quot;cmdquot;) lowsrcEM lineTo(x, y) queryCommandText(quot;cmdquot;) mimeTypeE6 moveTo(x, y) queryCommandValue(quot;cmdquot;) name quadraticCurveTo(cpx, cpy, x, y) scrollIntoView() namePropE rect(x, y, width, height) select() naturalHeightM restore() setEndPoint(quot;typequot;,range) naturalWidthM rotate(angle) protocolE save() src scale(x, y) startE stroke() useMap strokeRect(x, y, width, height) a vspace translate(x, y) 19 width xMS charsetE6MS yMS coordsE6MS hash host hostname selection 36 href hreflangE6MS area anchorNodeM addRange(range)M map 20 20 MethodsE anchorOffsetM clear()E mimeTypeE alt onscrollE focusNodeM collapse(node, offset)M areas[] (None) coords name focusOffsetM collapseToEnd()M name namePropE hash isCollapsedM collapseToStart()M host pathname rangeCountM containsNode(node, entireFlag)M hostname port typeE createRange()E href protocol typeDetailE deleteFromDocument()M noHref rel empty()E pathname rev TextRectangleE extend(node, offset)M 36 port search getRangeAt(rangeIndex)M shapeE6MS protocol bottom removeAllRanges()M search target left removeRange(range)M typeE6MS shape right selectAllChildren(elementRef )M urnE target top toString()M
  6. 6. JavaScript Bible, 6th Edition. ©2007 Danny Goodman (dannyg.com). All Rights Reserved. 6 JavaScript and Browser Objects Quick Reference form table 21 38 align createCaption() onscroll acceptCharset reset() onreset backgroundE createTFoot() action submit() onsubmit bgColor createTHead() autocompleteE border deleteCaption() elements[] borderColorE deleteRow(i) encodingEM borderColorDarkE deleteTFoot() enctypeE6MS borderColorLightE deleteTHead() length firstPage()E caption method cellPadding insertRow(i) name cellsE lastPage() target moveRow(srcIndex, destIndex)E cellSpacing colsE nextPage()E datePageSizeE previousPage()E input 22/23/24 refresh()E frame checked(checkbox, radio) select()(text, password) onchange(text) height complete(image) rows defaultChecked(checkbox, radio) rules summaryE6MS defaultValue(text, password) tbodies form maxLength(text) tFoot tHead name readOnly(text) width size(text) src(image) tbody, tfoot, thead type 38 value align deleteRow(i) bgColor insertRow(i) chE6MS moveRow(srcIndex, destIndex)E textarea 23 chOffE6MS rows cols createTextRange() onchange vAlign form select() name readOnly tr td, th rows 38 38 type abbrE6MS align deleteCell(i) value bgColor insertCell(i) align wrap axisE6MS borderColor backgroundE borderColorDark borderColorLight bgColor select 24 borderColorE cells chE6MS borderColorDarkE add(newOption[, index])E form onchange chOffE6MS borderColorLightE add(newOption, optionRef)MS length heightE cellIndex multiple remove(index) chE rowIndex name chOffE sectionRowIndex options[] vAlign colSpan options[i].defaultSelected headers options[i].index col, colgroup height 38 options[i].selected noWrap options[i].text align rowSpan options[i].value chE6MS vAlign selectedIndex chOffE6MS width size span type vAlign value width caption option 24 38 navigator 39 align defaultSelected vAlign appCodeName javaEnabled() form appMinorVersionE preference(name[, val])M(signed) label appName selected appVersion text browserLanguageE value cookieEnabled cpuClassE fieldset, legend 21 languageMS mimeTypesMS align onLineE screen 39 form oscpuMS platform availHeight pluginsMS availLeftMS label 21 productMS availTopMS productSubMS availWidth form securityPolicyM bufferDepthE htmlFor systemLanguageE colorDepth fontSmoothingEnabledE userAgent optgroupE6MS userLanguage height 24 userProfileE pixelDepth vendorMS updateIntervalE form vendorSubMS label width

×