Search completed in 2.53 seconds.
ByteLengthQueuingStrategy.ByteLengthQueuingStrategy() - Web APIs
the by
telengthqueuingstrategy() constructor creates and returns a by
telengthqueuingstrategy object instance.
... syntax var by
telengthqueuingstrategy = new by
telengthqueuingstrategy({highwatermark}); parameters {highwatermark} an object containing a highwatermark property.
... return value an instance of the by
telengthqueuingstrategy object.
...And 2 more matches
<input type="tel"> - HTML: Hypertext Markup Language
<input> elements of type
tel are used to let the user enter and edit a
telephone number.
... unlike <input type="email"> and <input type="url"> , the input value is not automatically validated to a particular format before the form can be submitted, because formats for
telephone numbers vary so much around the world.
... despite the fact that inputs of type
tel are functionally identical to standard text inputs, they do serve useful purposes; the most quickly apparent of these is that mobile browsers — especially on mobile phones — may opt to present a custom keypad optimized for entering phone numbers.
...And 39 more matches
HTMLSelectElement - Web APIs
the htmlselec
telement interface represents a <select> html element.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlselec
telement" target="_top"><rect x="321" y="65" width="170" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="406" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlselec
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interf...
... htmlselec
telement.autofocus a boolean reflecting the autofocus html attribute, which indicates whether the control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control.
...And 31 more matches
HTMLObjectElement - Web APIs
the htmlobjec
telement interface provides special properties and methods (beyond those on the htmlelement interface it also has available to it by inheritance) for manipulating the layout and presentation of <object> element, representing external resources.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlobjec
telement" target="_top"><rect x="321" y="65" width="170" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="406" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlobjec
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits pr...
... htmlobjec
telement.align is a domstring representing an enumerated property indicating alignment of the element's contents with respect to the surrounding context.
...And 30 more matches
HTMLScriptElement - Web APIs
html <script> elements expose the htmlscrip
telement interface, which provides special properties and methods for manipulating the behavior and execution of <script> elements (beyond the inherited htmlelement interface).
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlscrip
telement" target="_top"><rect x="321" y="65" width="170" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="406" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlscrip
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits pr...
... htmlscrip
telement.type is a domstring representing the mime type of the script.
...And 16 more matches
HTMLFieldSetElement - Web APIs
the htmlfieldse
telement interface provides special properties and methods (beyond the regular htmlelement interface it also has available to it by inheritance) for manipulating the layout and presentation of <fieldset> elements.
...ale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlfieldse
telement" target="_top"><rect x="301" y="65" width="190" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="396" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlfieldse
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits ...
... htmlfieldse
telement.disabled a boolean reflecting the disabled html attribute, indicating whether the user can interact with the control.
...And 15 more matches
HTMLOutputElement - Web APIs
the htmloutpu
telement interface provides properties and methods (beyond those inherited from htmlelement) for manipulating the layout and presentation of <output> elements.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmloutpu
telement" target="_top"><rect x="321" y="65" width="170" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="406" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmloutpu
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interf...
... htmloutpu
telement.defaultvalue a domstring representing the default value of the element, initially the empty string.
...And 15 more matches
HTMLInputElement - Web APIs
the htmlinpu
telement interface provides special properties and methods for manipulating the options, layout, and presentation of <input> elements.
...andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlinpu
telement" target="_top"><rect x="331" y="65" width="160" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="411" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlinpu
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties properties...
...this attribute applies when the value of the type attribute is text, search,
tel, url or email; otherwise it is ignored.
...And 14 more matches
SVGTextContentElement - Web APIs
the svgtextconten
telement interface is implemented by elements that support rendering child text content.
... it is inherited by various text-related interfaces, such as svgtex
telement, svgtspanelement, svgtrefelement, svgaltglyphelement and svgtextpathelement.
...roke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggraphicselement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="89" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgtextconten
telement" target="_top"><rect x="51" y="65" width="210" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="156" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtextconten
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} constants ...
...And 13 more matches
nsITelemetry
toolkit/components/
telemetry/nsi
telemetry.idlscriptable a service to gather performance data that can be tracked over time to allow generating histograms.
... 1.0 66 introduced gecko 6.0 inherits from: nsisupports last changed in gecko 7.0 (firefox 7.0 / thunderbird 7.0 / seamonkey 2.4) implemented by: @mozilla.org/base/
telemetry;1 as a service: let
telemetry = components.classes["@mozilla.org/base/
telemetry;1"] .getservice(components.interfaces.nsi
telemetry); method overview jsval gethistogrambyid(in acstring id); jsval snapshothistograms(in uint32_t adataset, in boolean asubsession, in boolean aclear); jsval getkeyedhistogrambyid(in acstring id); void capturestack(in acstring name); jsval snapshotcapturedstacks([optional] in boolean clear); nsisupports getloadedmodules(); jsval snapshotkeyedhistograms(in uint32_t adataset, in boolea...
...n asubsession, in boolean aclear); void sethistogramrecordingenabled(in acstring id, in boolean enabled); void asyncfetch
telemetrydata(in nsifetch
telemetrydatacallback acallback); double mssinceprocessstart(); void scalaradd(in acstring aname, in jsval avalue); void scalarset(in acstring aname, in jsval avalue); void scalarsetmaximum(in acstring aname, in jsval avalue); jsval snapshotscalars(in uint32_t adataset, [optional] in boolean aclear); void keyedscalaradd(in acstring aname, in astring akey, in jsval avalue); void keyedscalarset(in acstring aname, in astring akey, in jsval avalue); void keyedscalarsetmaximum(in acstring aname, in astring akey, in jsval avalue); jsval snapshotkeyedscalar...
...And 11 more matches
Document.getElementById() - Web APIs
the document method ge
telementbyid() returns an element object representing the element whose id property matches the specified string.
... syntax var element = document.ge
telementbyid(id); parameters id the id of the element to locate.
... example html <html> <head> <title>ge
telementbyid example</title> </head> <body> <p id="para">some text here</p> <button onclick="changecolor('blue');">blue</button> <button onclick="changecolor('red');">red</button> </body> </html> javascript function changecolor(newcolor) { var elem = document.ge
telementbyid('para'); elem.style.color = newcolor; } result usage notes the capitalization of "id" in the name of this method must be correct for the code to function; ge
telementbyid() is not valid and will not work, how...
...And 9 more matches
SVGFESpotLightElement - Web APIs
the svgfespotligh
telement interface corresponds to the <fespotlight> element.
...le mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgfespotligh
telement" target="_top"><rect x="271" y="65" width="210" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="376" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgfespotligh
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this in...
... svgfespotligh
telement.x read only an svganimatednumber corresponding to the x attribute of the given element.
...And 9 more matches
Document.getElementsByTagName() - Web APIs
the ge
telementsbytagname method of document interface returns an htmlcollection of elements with the given tag name.
...the returned htmlcollection is live, meaning that it updates itself automatically to stay in sync with the dom tree without having to call document.ge
telementsbytagname() again.
... syntax var elements = document.ge
telementsbytagname(name); elements is a live htmlcollection (but see the note below) of found elements in the order they appear in the tree.
...And 8 more matches
SVGRadialGradientElement - Web APIs
the svgradialgradien
telement interface corresponds to the <radialgradient> element.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svggradien
telement" target="_top"><rect x="301" y="65" width="180" height="50" fill="#fff" stroke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggradien
telement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="8...
...9" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgradialgradien
telement" target="_top"><rect x="21" y="65" width="240" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="141" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgradialgradien
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interface also inherits properties from its parent, svggradien
telement.
...And 8 more matches
SVGRectElement - Web APIs
the svgrec
telement interface provides access to the properties of <rect> elements, as well as methods to manipulate them.
...ill="#fff" stroke="#d4dde4" stroke-width="2px" /><text x="171" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggeometryelement</text></a><polyline points="81,89 71,84 71,94 81,89" stroke="#d4dde4" fill="none"/><line x1="71" y1="89" x2="41" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgrec
telement" target="_top"><rect x="-99" y="65" width="140" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="-29" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgrec
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interface...
... svgrec
telement.x read only returns an svganimatedlength corresponding to the x attribute of the given <rect> element.
...And 8 more matches
Element.getElementsByTagName() - Web APIs
the element.ge
telementsbytagname() method returns a live htmlcollection of elements with the given tag name.
...therefore, there is no need to call element.ge
telementsbytagname() with the same element and arguments repeatedly if the dom changes in between calls.
... when called on an html element in an html document, ge
telementsbytagname lower-cases the argument before searching for it.
...And 7 more matches
HTMLOListElement - Web APIs
the htmlolis
telement interface provides special properties (beyond those defined on the regular htmlelement interface it also has available to it by inheritance) for manipulating ordered list elements.
...andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlolis
telement" target="_top"><rect x="331" y="65" width="160" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="411" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlolis
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits pro...
... htmlolis
telement.reversed is a boolean value reflecting the reversed and defining if the numbering is descending, that is its value is true, or ascending (false).
...And 7 more matches
SVGLinearGradientElement - Web APIs
the svglineargradien
telement interface corresponds to the <lineargradient> element.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svggradien
telement" target="_top"><rect x="301" y="65" width="180" height="50" fill="#fff" stroke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggradien
telement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="8...
...9" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svglineargradien
telement" target="_top"><rect x="21" y="65" width="240" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="141" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svglineargradien
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interface also inherits properties from its parent, svggradien
telement.
...And 7 more matches
Document.getElementsByClassName() - Web APIs
the ge
telementsbyclassname method of document interface returns an array-like object of all child elements which have all of the given class name(s).
...you may also call ge
telementsbyclassname() on any element; it will return only elements which are descendants of the specified root element with the given class name(s).
... syntax var elements = document.ge
telementsbyclassname(names); // or: var elements = roo
telement.ge
telementsbyclassname(names); elements is a live htmlcollection of found elements.
...And 6 more matches
Document.getElementsByName() - Web APIs
the ge
telementsbyname() method of the document object returns a nodelist collection of elements with a given name in the document.
... syntax var elements = document.ge
telementsbyname(name); elements is a live nodelist collection, meaning it automatically updates as new elements with the same name are added to/removed from the document.
... example <!doctype html> <html lang="en"> <title>example: using document.ge
telementsbyname</title> <input type="hidden" name="up"> <input type="hidden" name="down"> <script> var up_names = document.ge
telementsbyname("up"); console.log(up_names[0].tagname); // displays "input" </script> </html> notes the name attribute can only be applied in (x)html documents.
...And 6 more matches
Element.getElementsByClassName() - Web APIs
the element method ge
telementsbyclassname() returns a live htmlcollection which contains every descendant element which has the specified class name or names.
... the method ge
telementsbyclassname() on the document interface works essentially the same way, except it acts on the entire document, starting at the document root.
... syntax var elements = element.ge
telementsbyclassname(names); parameters names a domstring containing one or more class names to match on, separated by whitespace.
...And 6 more matches
HTMLSelectElement.add() - Web APIs
the htmlselec
telement.add() method adds an element to the collection of option elements for this select element.
... exceptions a domerror of the type hierarchyrequesterror if the item passed to the method is an ancestor of the htmlselec
telement.
... append to an existing collection var sel = document.ge
telementbyid("existinglist"); var opt = document.createelement("option"); opt.value = "3"; opt.text = "option: value 3"; sel.add(opt, null); /* takes the existing following select object: <select id="existinglist"> <option value="1">option: value 1</option> <option value="2">option: value 2</option> </select> and changes it to: <select id="existinglist"> <option value="1">...
...And 6 more matches
JS_SetElement
syntax /* added in spidermonkey 31 */ bool js_se
telement(jscontext *cx, js::handleobject obj, uint32_t index, js::handlevalue v); bool js_se
telement(jscontext *cx, js::handleobject obj, uint32_t index, js::handleobject v); bool js_se
telement(jscontext *cx, js::handleobject obj, uint32_t index, js::handlestring v); bool js_se
telement(jscontext *cx, js::handleobject obj, uint32_t index, int32_t v); bool js_se
telement(jscontext *cx, js::handleobject obj, uint32_t index, uint32_t v); bool js_se
telement(jscontext *cx, js::handleobject obj, uint32_t index, double v); /* obsolete since jsapi 29 */ bool js_se
telement(jscontext *cx, js::handleobjec...
...js_se
telement ordinarily leaves *vp unchanged, but a jsclass.addproperty hook or non-default setter may modify it.
... obsolete since jsapi 29 description js_se
telement assigns a value to a numeric property of an object.
...And 5 more matches
Document.getElementsByTagNameNS() - Web APIs
syntax elements = document.ge
telementsbytagnamens(namespace, name) elements is a live nodelist (but see the note below) of found elements in the order they appear in the tree.
...see the note in browser compatibility section in element.ge
telementsbytagnamens for details.
... example in the following example ge
telementsbytagnamens starts from a particular parent element, and searches topdown recursively through the dom from that parent element, looking for child elements matching the tag name parameter.
...And 5 more matches
Element.insertAdjacentElement() - Web APIs
the insertadjacen
telement() method of the element interface inserts a given element node at a given position relative to the element it is invoked upon.
... syntax targe
telement.insertadjacen
telement(position, element); parameters position a domstring representing the position relative to the targe
telement; must match (case-insensitively) one of the following strings: 'beforebegin': before the targe
telement itself.
... 'afterbegin': just inside the targe
telement, before its first child.
...And 5 more matches
HTMLInputElement.setSelectionRange() - Web APIs
the htmlinpu
telement.setselectionrange() method sets the start and end positions of the current text selection in an <input> or <textarea> element.
... this method updates the htmlinpu
telement.selectionstart, selectionend, and selectiondirection properties in one call.
... note that accordingly to the whatwg forms spec selectionstart, selectionend properties and setselectionrange method apply only to inputs of types text, search, url,
tel and password.
...And 5 more matches
HTMLUListElement - Web APIs
the htmlulis
telement interface provides special properties (beyond those defined on the regular htmlelement interface it also has available to it by inheritance) for manipulating unordered list elements.
...andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmlulis
telement" target="_top"><rect x="331" y="65" width="160" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="411" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlulis
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits pro...
... htmlulis
telement.type is a domstring value reflecting the type and defining the kind of marker to be used to display.
...And 5 more matches
SVGForeignObjectElement - Web APIs
the svgforeignobjec
telement interface provides access to the properties of <foreignobject> elements, as well as methods to manipulate them.
...ke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggraphicselement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="89" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgforeignobjec
telement" target="_top"><rect x="31" y="65" width="230" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="146" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgforeignobjec
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this i...
... svgforeignobjec
telement.x read only an svganimatedlength corresponding to the x attribute of the given <foreignobject> element.
...And 5 more matches
Debug.writeln - Archive of obsolete content
the debug.wri
teln function sends strings to the script debugger, followed by a newline character.
... syntax debug.wri
teln([str1 [, str2 [, ...
... remarks the debug.wri
teln function sends strings, followed by a newline character, to the immediate window of the microsoft script debugger at run time.
...And 4 more matches
ByteLengthQueuingStrategy - Web APIs
the by
telengthqueuingstrategy interface of the the streams api provides a built-in byte length queuing strategy that can be used when constructing streams.
... constructor by
telengthqueuingstrategy() creates a new by
telengthqueuingstrategy object instance.
... methods by
telengthqueuingstrategy.size() returns the given chunk’s by
telength property.
...And 4 more matches
HTMLBaseFontElement - Web APIs
the htmlbasefon
telement interface provides special properties (beyond the regular htmlelement interface it also has available to it by inheritance) for manipulating <basefont> elements.
...this latest specification requires that this element implements htmlunknownelement rather than htmlbasefon
telement.
... htmlbasefon
telement.color is a domstring representing the text color using either a named color or a color specified in the hexadecimal #rrggbb format.
...And 4 more matches
HTMLDListElement - Web APIs
the htmldlis
telement interface provides special properties (beyond those of the regular htmlelement interface it also has available to it by inheritance) for manipulating definition list (<dl>) elements.
...andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmldlis
telement" target="_top"><rect x="331" y="65" width="160" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="411" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmldlis
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits pro...
... htmldlis
telement.compact is a boolean indicating that spacing between list items should be reduced.
...And 4 more matches
SVGFEOffsetElement - Web APIs
the svgfeoffse
telement interface corresponds to the <feoffset> element.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgfeoffse
telement" target="_top"><rect x="301" y="65" width="180" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgfeoffse
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this inter...
... svgfeoffse
telement.in1 read only an svganimatedstring corresponding to the in attribute of the given element.
...And 4 more matches
SVGFEPointLightElement - Web APIs
the svgfepointligh
telement interface corresponds to the <fepointlight> element.
...e mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgfepointligh
telement" target="_top"><rect x="261" y="65" width="220" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="371" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgfepointligh
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this i...
... svgfepointligh
telement.x read only an svganimatednumber corresponding to the x attribute of the given element.
...And 4 more matches
SVGGradientElement - Web APIs
the svggradient interface is a base interface used by svglineargradien
telement and svgradialgradien
telement.
...ndale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svggradien
telement" target="_top"><rect x="301" y="65" width="180" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggradien
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} constants na...
... svggradien
telement.gradientunits read only returns an svganimatedenumeration corresponding to the gradientunits attribute on the given element.
...And 4 more matches
Element.getElementsByTagNameNS() - Web APIs
the element.ge
telementsbytagnamens() method returns a live htmlcollection of elements with the given tag name belonging to the given namespace.
... it is similar to document.ge
telementsbytagnamens, except that its search is restricted to descendants of the specified element.
... syntax elements = element.ge
telementsbytagnamens(namespaceuri, localname) elements is a live htmlcollection of found elements in the order they appear in the tree.
...And 3 more matches
HTMLSelectElement.remove() - Web APIs
the htmlselec
telement.remove() method removes the element at the specified index from the options collection for this select element.
... example var sel = document.ge
telementbyid("existinglist"); sel.remove(1); /* takes the existing following select object: <select id="existinglist" name="existinglist"> <option value="1">option: value 1</option> <option value="2">option: value 2</option> <option value="3">option: value 3</option> </select> and changes it to: <select id="existinglist" name="existinglist"> <option value="1">option: value 1</option> <option value="3">option: value 3</option> </select> */ specifications specification status comment html living standardthe defi...
...nition of 'htmlselec
telement.remove()' in that specification.
...And 3 more matches
HTMLSelectElement.type - Web APIs
the htmlselec
telement.type read-only property returns the form control's type.
... syntax var str = selec
telt.type; the possible values are: "select-multiple" if multiple values can be selected.
... example switch (select.type) { case 'select-multiple': // multiple values may be selected break; case 'select-one': // only one value may be selected break; default: // non-standard value (or this isn't a select element) } specifications specification status comment html living standardthe definition of 'htmlselec
telement' in that specification.
...And 3 more matches
HTMLSlotElement - Web APIs
the htmlslo
telement interface of the shadow dom api enables access to the name and assigned nodes of an html <slot> element.
... properties htmlslo
telement.name domstring: can be used to get and set the slot's name.
... methods htmlslo
telement.assignednodes() returns a sequence of the nodes assigned to this slot, and if the flatten option is set to true, the assigned nodes of any other slots that are descendants of this slot.
...And 3 more matches
NonDocumentTypeChildNode.nextElementSibling - Web APIs
the nondocumenttypechildnode.nex
telementsibling read-only property returns the element immedia
tely following the specified one in its parent's children list, or null if the specified element is the last one in the list.
... syntax var nextnode = elementnodereference.nex
telementsibling; example <div id="div-01">here is div-01</div> <div id="div-02">here is div-02</div> <script type="text/javascript"> var el = document.ge
telementbyid('div-01').nex
telementsibling; console.log('siblings of div-01:'); while (el) { console.log(el.nodename); el = el.nex
telementsibling; } </script> this example outputs the following into the console when it loads: siblings of div-01: div script polyfill for internet explorer 8 this property is unsupported prior to ie9, so the following snippet can be used to add support to ie8: // source: https://github.com/alhadis/snippets/blob/master/js/polyfills/ie8-child-elements.js if(!("nex
telementsibling" in document.documen
telement)){ object.defineproperty(elemen...
...t.prototype, "nex
telementsibling", { get: function(){ var e = this.nextsibling; while(e && 1 !== e.nodetype) e = e.nextsibling; return e; } }); } polyfill for internet explorer 9+ and safari // source: https://github.com/jserz/js_piece/blob/master/dom/nondocumenttypechildnode/nex
telementsibling/nex
telementsibling.md (function (arr) { arr.foreach(function (item) { if (item.hasownproperty('nex
telementsibling')) { return; } object.defineproperty(item, 'nex
telementsibling', { configurable: true, enumerable: true, get: function () { var el = this; while (el = el.nextsibling) { if (el.nodetype === 1) { return el; } } return...
...And 3 more matches
SVGFEDistantLightElement - Web APIs
the svgfedistantligh
telement interface corresponds to the <fedistantlight> element.
...mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgfedistantligh
telement" target="_top"><rect x="241" y="65" width="240" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="361" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgfedistantligh
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this...
... svgfedistantligh
telement.azimuth read only an svganimatednumber corresponding to the azimuth attribute of the given element.
...And 3 more matches
JS_GetElement
syntax bool js_ge
telement(jscontext *cx, js::handleobject obj, uint32_t index, js::mutablehandlevalue vp); name type description cx jscontext * the context in which to perform the property lookup.
... description js_ge
telement examines a specified js object, obj, and its prototype chain, for an element or numeric property numbered index.
... if the element exists, js_ge
telement sets *vp to the element's current value.
...And 2 more matches
CanvasRenderingContext2D.createLinearGradient() - Web APIs
the canvasrenderingcontext2d.crea
telineargradient() method of the canvas 2d api creates a gradient along the line connecting two given coordinates.
... syntax canvasgradient ctx.crea
telineargradient(x0, y0, x1, y1); the crea
telineargradient() method is specified by four parameters defining the start and end points of the gradient line.
... examples filling a rectangle with a linear gradient this example initializes a linear gradient using the crea
telineargradient() method.
...And 2 more matches
Document.rootElement - Web APIs
document.roo
telement returns the element that is the root element of the document if it is an <svg> element, otherwise null.
... it is deprecated in favor of document.documen
telement, which returns the root element for all documents.
... syntax const element = document.roo
telement notes if the document is a non-empty svg document, then the roo
telement will be an svgsvgelement, identical to the documen
telement.
...And 2 more matches
Document.writeln() - Web APIs
syntax document.wri
teln(line); parameters line is string containing a line of text.
... example document.wri
teln("<p>enter password:</p>"); notes document.wri
teln is the same as document.write but adds a newline.
... note: document.wri
teln (like document.write) does not work in xhtml documents (you'll get a "operation is not supported" (ns_error_dom_not_supported_err) error on the error console).
...And 2 more matches
HTMLDataListElement - Web APIs
the htmldatalis
telement interface provides special properties (beyond the htmlelement object interface it also has available to it by inheritance) to manipulate <datalist> elements and their content.
...ale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmlelement</text></a><polyline points="491,25 501,20 501,30 491,25" stroke="#d4dde4" fill="none"/><line x1="501" y1="25" x2="509" y2="25" stroke="#d4dde4"/><line x1="509" y1="25" x2="509" y2="90" stroke="#d4dde4"/><line x1="509" y1="90" x2="492" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/htmldatalis
telement" target="_top"><rect x="301" y="65" width="190" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="396" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">htmldatalis
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties inherits ...
...properties from its parent, htmlelement htmldatalis
telement.options read only is a htmlcollection representing a collection of the contained option elements.
...And 2 more matches
HTMLFrameSetElement - Web APIs
the htmlframese
telement interface provides special properties (beyond those of the regular htmlelement interface they also inherit) for manipulating <frameset> elements.
... htmlframese
telement.cols is a domstring structured as a comma-seperated list specifing the width of each column inside a frameset.
... htmlframese
telement.rows is a domstring structured as a comma-seperated list specifing the height of each column inside a frameset.
...And 2 more matches
HTMLSelectElement.selectedOptions - Web APIs
the read-only htmlselec
telement property selectedoptions contains a list of the <option> elements contained within the <select> element that are currently selected.
... syntax var selectedcollection = htmlselec
telement.selectedoptions; value an htmlcollection which lists every currently selected htmloptionelement which is either a child of the htmlselec
telement or of an htmloptgroupelement within the <select> element.
... javascript the javascript code that establishes the event handler for the button, as well as the event handler itself, looks like this: let orderbutton = document.ge
telementbyid("order"); let itemlist = document.ge
telementbyid("foods"); let outputbox = document.ge
telementbyid("output"); orderbutton.addeventlistener("click", function() { let collection = itemlist.selectedoptions; let output = ""; for (let i=0; i<collection.length; i++) { if (output === "") { output = "your order for the following items has been placed: "; } output += col...
...And 2 more matches
ParentNode.firstElementChild - Web APIs
the parentnode.firs
telementchild read-only property returns the object's first child element, or null if there are no child elements.
...in this case, firs
telementchild moved to parentnode.
... syntax var element = node.firs
telementchild; example <ul id="foo"> <li>first (1)</li> <li>second (2)</li> <li>third (3)</li> </ul> <script> var foo = document.ge
telementbyid('foo'); // yields: first (1) console.log(foo.firs
telementchild.textcontent); </script> polyfill for ie8, ie9 and safari // overwrites native 'firs
telementchild' prototype.
...And 2 more matches
ParentNode.lastElementChild - Web APIs
the parentnode.las
telementchild read-only property returns the object's last child element or null if there are no child elements.
...in this case, las
telementchild moved to parentnode.
... syntax const element = node.las
telementchild example <ul id="foo"> <li>first (1)</li> <li>second (2)</li> <li>third (3)</li> </ul> <script> const foo = document.ge
telementbyid('foo'); console.log(foo.las
telementchild.textcontent); // logs: third (3) </script> polyfill the code below adds support of las
telementchild() to document and documentfragment in internet explorer and safari.
...And 2 more matches
SVGScriptElement - Web APIs
the svgscrip
telement interface corresponds to the svg <script> element.
...,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgelement</text></a><polyline points="481,25 491,20 491,30 481,25" stroke="#d4dde4" fill="none"/><line x1="491" y1="25" x2="499" y2="25" stroke="#d4dde4"/><line x1="499" y1="25" x2="499" y2="90" stroke="#d4dde4"/><line x1="499" y1="90" x2="482" y2="90" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgscrip
telement" target="_top"><rect x="321" y="65" width="160" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="401" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgscrip
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties svgscripte...
... svgscrip
telement.crossorigin read only a domstring corresponding to the crossorigin attribute of the given <script> element.
...And 2 more matches
SVGTextElement - Web APIs
the svgtex
telement interface corresponds to the <text> elements.
...roke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggraphicselement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="89" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgtextconten
telement" target="_top"><rect x="51" y="65" width="210" height="50" fill="#fff" stroke="#d4dde4" stroke-width="2px" /><text x="156" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtextconten
telement</text></a><polyline points="51,89 41,84 41,94 51,89" stroke="#d4dde4" fill="none"/><line x1="41" y1="89" ...
...d4dde4" stroke-width="2px" /><text x="-114" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtextpositioningelement</text></a><polyline points="-239,89 -249,84 -249,94 -239,89" stroke="#d4dde4" fill="none"/><line x1="-249" y1="89" x2="-279" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgtex
telement" target="_top"><rect x="-419" y="65" width="140" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="-349" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtex
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interfa...
...And 2 more matches
Document.documentElement - Web APIs
document.documen
telement returns the element that is the root element of the document (for example, the <html> element for html documents).
... syntax const element = document.documen
telement example const roo
telement = document.documen
telement; const firsttier = roo
telement.childnodes; // firsttier is a nodelist of the direct children of the root element // such as <head> and <body> for (const child of firsttier) { // do something with each direct child of the root element } notes for any non-empty html document, documen
telement will always be an <html> element.
... for any non-empty xml document, documen
telement will always be whatever element is the root element of the document.
... specifications specification status comment domthe definition of 'document.documen
telement' in that specification.
HTMLScriptElement.referrerPolicy - Web APIs
the referrerpolicy property of the htmlscrip
telement interface reflects the html referrerpolicy of the <script> element and fetches made by that script, defining which referrer is sent when fetching the resource.
... syntax refstr = scrip
telem.referrerpolicy; scrip
telem.referrerpolicy = refstr; value a domstring; one of the following: no-referrer the referer header will be omitted entirely.
... examples var scrip
telem = document.createelement("script"); scrip
telem.src = "/"; scrip
telem.referrerpolicy = "unsafe-url"; document.body.appendchild(script); specifications specification status comment referrer policythe definition of 'referrerpolicy attribute' in that specification.
... html living standardthe definition of 'htmlscrip
telement: referrerpolicy' in that specification.
HTMLSelectElement.disabled - Web APIs
the htmlselec
telement.disabled is a boolean that reflects the disabled html attribute, which indicates whether the control is disabled.
... syntax edit aselec
telement.disabled = abool; example html <label> allow drinks?
... <input id="allow-drinks" type="checkbox"/> </label> <label for="drink-select">drink selection:</label> <select id="drink-select" disabled> <option value="1">water</option> <option value="2">beer</option> <option value="3">pepsi</option> <option value="4">whisky</option> </select> javascript var allowdrinkscheckbox = document.ge
telementbyid("allow-drinks"); var drinkselect = document.ge
telementbyid("drink-select"); allowdrinkscheckbox.addeventlistener("change", function(event) { if (event.target.checked) { drinkselect.disabled = false; } else { drinkselect.disabled = true; } }, false); result specifications specification status comment html living standardthe definition of 'disabled' in that specification.
... living standard html5the definition of 'htmlselec
telement' in that specification.
HTMLSelectElement.form - Web APIs
the htmlselec
telement.form read-only property returns a htmlformelement representing the form that this element is associated with.
... syntax edit aform = aselec
telement.form.selectname; example html <form action="http://www.google.com/search" method="get"> <label>google: <input type="search" name="q"></label> <input type="submit" value="search..."> </form> javascript a property available on all form elements, "type" returns the type of the calling form element.
...the below code gives all select elements in a particular form a css class of "selectclass": <script type="text/javascript"> var form_element = document.ge
telementbyid('subscribe_form'); var vist = form_element.style; if (vist.display=='' || vist.display=='none') { vist.display = 'block'; } else { vist.display = 'none'; } </script> specifications specification status comment html living standardthe definition of 'form' in that specification.
... living standard html5the definition of 'htmlselec
telement' in that specification.
HTMLSelectElement.item() - Web APIs
the htmlselec
telement.item() method returns the element corresponding to the htmloptionelement whose position in the options list corresponds to the index given in the parameter, or null if there are none.
... in javascript, using the array bracket syntax with an unsigned long, like selec
telt[index] is equivalent to selec
telt.nameditem(index).
... examples html <form> <select id="myformcontrol" type="textarea"> <option id="o1">opt 1</option> <option id="o2">opt 2</option> </select> </form> javascript // returns the htmloptionelement representing #o2 elem1 = document.forms[0]['myformcontrol'][1]; specifications specification status comment html living standardthe definition of 'htmlselec
telement.item()' in that specification.
... html5the definition of 'htmlselec
telement.item()' in that specification.
HTMLSelectElement.namedItem() - Web APIs
the htmlselec
telement.nameditem() method returns the htmloptionelement corresponding to the htmloptionelement whose name or id match the specified name, or null if no option matches.
... in javascript, using the array bracket syntax with a string, like selec
telt["value"] is equivalent to selec
telt.nameditem("value").
... example html <form> <select id="myformcontrol"> <option id="o1">opt 1</option> <option id="o2">opt 2</option> </select> </form> javascript elem1 = document.forms[0]['myformcontrol']['o1']; // returns the htmloptionelement representing #o1 specifications specification status comment html living standardthe definition of 'htmlselec
telement.nameditem()' in that specification.
... html5the definition of 'htmlselec
telement.nameditem()' in that specification.
HTMLSelectElement.setCustomValidity() - Web APIs
the htmlselec
telement.setcustomvalidity() method sets the custom validity message for the selection element to the specified message.
... syntax selec
telt.setcustomvalidity(string); parameters string is the domstring containing the error message.
... specifications specification status comment html living standardthe definition of 'htmlselec
telement.setcustomvalidity()' in that specification.
... html5the definition of 'htmlselec
telement.setcustomvalidity()' in that specification.
SVGSetElement - Web APIs
the svgse
telement interface corresponds to the <set> element.
...fff" stroke="#d4dde4" stroke-width="2px" /><text x="386" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svganimationelement</text></a><polyline points="291,89 281,84 281,94 291,89" stroke="#d4dde4" fill="none"/><line x1="281" y1="89" x2="251" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgse
telement" target="_top"><rect x="121" y="65" width="130" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="186" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgse
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interface ...
... specifications specification status comment svg animations level 2the definition of 'svgse
telement' in that specification.
... editor's draft no change scalable vector graphics (svg) 1.1 (second edition)the definition of 'svgse
telement' in that specification.
<tt>: The Teletype Text element (obsolete) - HTML: Hypertext Markup Language
the obsolete html
teletype text element (<tt>) creates inline text which is presented using the user agent's default monospace font face.
... this element was created for the purpose of rendering text as it would be displayed on a fixed-width display such as a
teletype, text-only screen, or line printer.
... <p>enter the following at the
telnet command prompt: <code>set localecho</code><br /> the
telnet client should display: <tt>local echo is on</tt></p> result overriding the default font you can override the browser's default font—if the browser permits you to do so, which it isn't required to do—using css: css tt { font-family: "lucida console", "menlo", "monaco", "courier", monospace; } html <p>ent...
...er the following at the
telnet command prompt: <code>set localecho</code><br /> the
telnet client should display: <tt>local echo is on</tt></p> result usage notes the <tt> element is, by default, rendered using the browser's default non-proportional font.
DataView.prototype.byteLength - JavaScript
the by
telength accessor property represents the length (in bytes) of this view from the start of its arraybuffer or sharedarraybuffer.
... description the by
telength property is an accessor property whose set accessor function is undefined, meaning that you can only read this property.
...if the dataview is not specifying an offset or a by
telength, the by
telength of the referenced arraybuffer or sharedarraybuffer will be returned.
... examples using the by
telength property var buffer = new arraybuffer(8); var dataview = new dataview(buffer); dataview.by
telength; // 8 (matches the by
telength of the buffer) var dataview2 = new dataview(buffer, 1, 5); dataview2.by
telength; // 5 (as specified when constructing the dataview) var dataview3 = new dataview(buffer, 2); dataview3.by
telength; // 6 (due to the offset of the constructed dataview) specifications specification ecmascript (ecma-262)the definition of 'dataview.prototype.by
telength' in that specification.
Intel Power Gadget
in
tel power gadget provides real-time graphs of various power-related measures and estimates, all taken from the in
tel rapl msrs.
... in
tel power gadget can also log these results to a file.
...unfortuna
tely, the gecko profiler takes 1000 samples per second on desktop and is cpu intensive and so is likely to skew the rapl estimates significantly, so the api integration was removed.
ByteLengthQueuingStrategy.size() - Web APIs
the size() method of the by
telengthqueuingstrategy interface returns the given chunk’s by
telength property.
... syntax var size = by
telengthqueuingstrategy.size(chunk); parameters chunk a chunk of data being passed through the stream.
... examples const queuingstrategy = new by
telengthqueuingstrategy({ highwatermark: 1 }); const readablestream = new readablestream({ start(controller) { ...
HTMLContentElement - Web APIs
the htmlconten
telement interface represents a <content> html element, which is used in shadow dom.
... htmlconten
telement.select is a domstring that reflects the select html attribute.
... htmlconten
telement.getdistributednodes() returns a static nodelist of the distributed nodes associated with this <content> element.
HTMLFontElement - Web APIs
htmlfon
telement.color is a domstring that reflects the color html attribute, containing either a named color or a color specified in the hexadecimal #rrggbb format.
... htmlfon
telement.face is a domstring that reflects the face html attribute, containing a comma-separated list of one or more font names.
... htmlfon
telement.size is a domstring that reflects the size html attribute, containing either a font size number ranging from 1 to 7 or a relative size to the size attribute of the <basefont> element, for example -2 or +1.
HTMLInputElement.mozGetFileNameArray() - Web APIs
the htmlinpu
telement.mozgetfilenamearray() method returns an array of the names of the files that were selected by the user on an html input element.
... syntax inpu
telement.mozgetfilenamearray(alength, afilenames); parameters alength if specified, will receive the number of file names in the returned array.
... example var numfiles = 0; var filearray = {}; inpu
telement.mozgetfilenamearray(numfiles, filearray); ...
HTMLInputElement.mozSetFileNameArray() - Web APIs
the htmlinpu
telement.mozsetfilenamearray() method sets the names of the files that selected on an html input element.
... syntax inpu
telement.mozsetfilenamearray(afilenames, alength); parameters afilenames is the array of file names to apply to the element.
... example var filearray = {"/foo/bar.txt", "/foo/foosball.txt"}; inpu
telement.mozsetfilenamearray(filearray, filearray.length); ...
HTMLInputElement.select() - Web APIs
the htmlinpu
telement.select() method selects all the text in a <textarea> element or in an <input> element that includes a text field.
... html <input type="text" id="text-box" size="20" value="hello world!"> <button onclick="selecttext()">select text</button> javascript function selecttext() { const input = document.ge
telementbyid('text-box'); input.focus(); input.select(); } result notes calling element.select() will not necessarily focus the input, so it is often used with htmlelement.focus().
... in browsers where it is not supported, it is possible to replace it with a call to htmlinpu
telement.setselectionrange() with parameters 0 and the input's value length: <input onclick="this.select();" value="sample text" /> <!-- equivalent to --> <input onclick="this.setselectionrange(0, this.value.length);" value="sample text" /> specifications specification status comment html living standardthe definition of 'select' in that specification.
HTMLInputElement.setRangeText() - Web APIs
the htmlinpu
telement.setrangetext() method replaces a range of text in an <input> or <textarea> element with a new string.
... html <input type="text" id="text-box" size="30" value="this text has not been updated."> <button onclick="selecttext()">update text</button> javascript function selecttext() { const input = document.ge
telementbyid('text-box'); input.focus(); input.setrangetext('already', 14, 17, 'select'); } result specifications specification status comment html living standardthe definition of 'htmlinpu
telement.setselectionrange()' in that specification.
... living standard no change html5the definition of 'htmlinpu
telement.setselectionrange()' in that specification.
HTMLInputElement.stepDown() - Web APIs
the htmlinpu
telement.stepdown([n]) method decrements the value of a numeric type of <input> element by the value of the step attribute or up to n multiples of the step attribute if a number is passed as the parameter.
... htmlinpu
telement.stepdown() decrements the value by (step * n), where n defaults to 1 if not specified.
...by 5: <input type="number" step="5" id="thenumber" min="0" max="400"> </label> </p> <p> <label>enter how many values of step you would like to increment by or leave it blank: <input type="number" step="1" id="decrementer" min="-2" max="15"> </label> </p> <input type="button" value="decrement" id="thebutton"> javascript /* make the button call the function */ let button = document.ge
telementbyid('thebutton'); button.addeventlistener('click', function() { stepondown();} ); function stepondown() { let input = document.ge
telementbyid('thenumber'); let val = document.ge
telementbyid('decrementer').value; if (val) { /* increment with a parameter */ input.stepdown(val); } else { /* or without a parameter.
HTMLInputElement.webkitEntries - Web APIs
the read-only webkitentries property of the htmlinpu
telement interface contains an array of file system entries (as objects based on filesystementry) representing files and/or directories selected by the user using an <input> element of type file, but only if that selection was made using drag-and-drop: selecting a file in the dialog will leave the property empty (bug 1326031).
... syntax var entries = htmlinpu
telement.webkitentries; value an array of objects based on filesystementry, each representing one file which is selected in the <input> element.
... html <input id="files" type="file" multiple> javascript document.ge
telementbyid("files").addeventlistener("change", function(event) { event.target.webkitentries.foreach(function(entry) { /* do stuff with the entry */ }); }); each time a change event occurs, this code iterates over the selected files, obtaining their filesystementry-based objects and acting on them.
HTMLInputElement.webkitdirectory - Web APIs
the htmlinpu
telement.webkitdirectory is a property that reflects the webkitdirectory html attribute and indicates that the <input> element should let the user select directories instead of files.
... syntax htmlinpu
telement.webkitdirectory = boolvalue value a boolean; true if the <input> element should allow picking only directories or false if only files should be selectable.
... html content <input type="file" id="filepicker" name="filelist" webkitdirectory multiple /> <ul id="listing"></ul> javascript content document.ge
telementbyid("filepicker").addeventlistener("change", function(event) { let output = document.ge
telementbyid("listing"); let files = event.target.files; for (let i=0; i<files.length; i++) { let item = document.createelement("li"); item.innerhtml = files[i].webkitrelativepath; output.appendchild(item); }; }, false); result specifications specification status c...
HTMLObjectElement.setCustomValidity - Web APIs
the setcustomvalidity() method of the htmlobjec
telement interface sets a custom validity message for the element.
... syntax htmlobjec
telement.setcustomvalidity(message); parameters error the message to use for validity errors.
... function validate(inputid) { var input = document.ge
telementbyid(inputid); var validitystate_object = input.validity; if (validitystate_object.valuemissing) { input.setcustomvalidity('you gotta fill this out, yo!'); input.reportvalidity(); } else if (input.rangeunderflow) { input.setcustomvalidity('we need a higher number!'); input.reportvalidity(); } else if (input.rangeoverflow) { input.setcustomvalidity('thats too high!'); input.reportvalidity(); } else { input.s...
HTMLObjectElement.typeMustMatch - Web APIs
the htmlobjec
telement.typemustmatch property is a boolean that reflects the typemustmatch attribute of the <object> element.
... it indicates if the resource linked by it must match the mime type given by htmlobjec
telement.type in order for this resource to be used.
... syntax var mustmatch = obj.typemustmatch; obj.typemustmatch = mustmatch; example html <object id="obj" data="move.swf" type="application/x-shockwave-flash" typemustmatch></object> javascript let obj = document.ge
telementbyid('obj'); console.log(obj.typemustmatch); specifications specification status comment html5the definition of 'htmlobjec
telement' in that specification.
HTMLObjectElement.willValidate - Web APIs
the willvalidate read-only property of the htmlobjec
telement interface returns a boolean that indicates whether the element is a candidate for constraint validation.
... always false for htmlobjec
telement objects.
... syntax var boolean = htmlobjec
telement.willvalidate; value a boolean.
HTMLSelectElement.autofocus - Web APIs
the htmlselec
telement.autofocus property is a boolean that reflects the autofocus html attribute, which indicates whether the associated <select> element will get input focus when the page loads, unless the user overrides it.
... setting this property doesn't set the focus to the associated <select> element: it merely
tells the browser to focus to it when the element is inserted in the document.
... syntaxedit abool = aselec
telement.autofocus; // get the value of autofocus aselec
telement.autofocus = abool; // set the value of autofocus example html <select id="myselect" autofocus> <option>option 1</option> <option>option 2</option> </select> javascript // check if the autofocus attribute on the <select> var hasautofocus = document.ge
telementbyid('myselect').autofocus; specifications specification status comment html living standardthe definition of 'autofocus' in that specification.
HTMLSelectElement.checkValidity() - Web APIs
the htmlselec
telement.checkvalidity() method checks whether the element has any constraints and whether it satisfies them.
... syntax var result = selec
telt.checkvalidity(); specifications specification status comment html living standardthe definition of 'htmlselec
telement.checkvalidity()' in that specification.
... html5the definition of 'htmlselec
telement.checkvalidity()' in that specification.
HTMLSelectElement.selectedIndex - Web APIs
the htmlselec
telement.selectedindex is a long that reflects the index of the first or last selected <option> element, depending on the value of multiple.
... syntax var index = selec
telem.selectedindex; selec
telem.selectedindex = index; example html <p id="p">selectedindex: 0</p> <select id="select"> <option selected>option a</option> <option>option b</option> <option>option c</option> <option>option d</option> <option>option e</option> </select> javascript var selec
telem = document.ge
telementbyid('select') var pelem = document.ge
telementbyid('p') // when a new <option> is selected selec
telem.addeventlistener('change', function() { var index = selec
telem.selectedindex; // add that data to the <p> pelem.innerhtml = 'selectedindex: ' + index; }) specifications specification status comment html living standardthe definition of 'htmlselec
telemen...
... html5the definition of 'htmlselec
telement' in that specification.
Node.parentElement - Web APIs
the node.paren
telement read-only property returns the dom node's parent element, or null if the node either has no parent, or its parent isn't a dom element.
... syntax paren
telement = node.paren
telement paren
telement is the parent element of the current node.
... example if (node.paren
telement) { node.paren
telement.style.color = "red"; } specifications specification status comment domthe definition of 'paren
telement' in that specification.
targetElement - Web APIs
the svganimationelement.targe
telement property refers to the element which is being animated.
... syntax var targe
telement = someelement.targe
telement; specifications specification status comment svg animations level 2the definition of 'svganimationelement.targe
telement' in that specification.
... scalable vector graphics (svg) 1.1 (second edition)the definition of 'svganimationelement.targe
telement' in that specification.
SVGFontElement - Web APIs
the svgfon
telement interface corresponds to the <font> elements.
... <div id="interfacediagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 23.333333333333332%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 140" preserveaspectratio="xminymin meet"><a xlink:href="/docs/web/api/svgfon
telement" target="_top"><rect x="1" y="1" width="140" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="71" y="30" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgfon
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interface has...
... specifications specification status comment scalable vector graphics (svg) 1.1 (second edition)the definition of 'svgfon
telement' in that specification.
SVGFontFaceFormatElement - Web APIs
the svgfontfaceforma
telement interface corresponds to the <font-face-format> elements.
... <div id="interfacediagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 23.333333333333332%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 140" preserveaspectratio="xminymin meet"><a xlink:href="/docs/web/api/svgfontfaceforma
telement" target="_top"><rect x="1" y="1" width="240" height="50" fill="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="121" y="30" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgfontfaceforma
telement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this in...
... specifications specification status comment scalable vector graphics (svg) 1.1 (second edition)the definition of 'svgfontfaceforma
telement' in that specification.
SyntaxError: identifier starts immediately after numeric literal - JavaScript
the javascript exception "identifier starts immedia
tely after numeric literal" occurs when an identifier started with a digit.
... message syntaxerror: unexpected identifier after numeric literal (edge) syntaxerror: identifier starts immedia
tely after numeric literal (firefox) syntaxerror: unexpected number (chrome) error type syntaxerror what went wrong?
...the following fails: var 1life = 'foo'; // syntaxerror: identifier starts immedia
tely after numeric literal var foo = 1life; // syntaxerror: identifier starts immedia
tely after numeric literal alert(1.foo); // syntaxerror: identifier starts immedia
tely after numeric literal you will need to rename your variable to avoid the leading number.
ArrayBuffer.prototype.byteLength - JavaScript
the by
telength accessor property represents the length of an arraybuffer in bytes.
... description the by
telength property is an accessor property whose set accessor function is undefined, meaning that you can only read this property.
... examples using by
telength var buffer = new arraybuffer(8); buffer.by
telength; // 8 specifications specification ecmascript (ecma-262)the definition of 'arraybuffer.prototype.by
telength' in that specification.
SharedArrayBuffer.prototype.byteLength - JavaScript
the by
telength accessor property represents the length of an sharedarraybuffer in bytes.
... description the by
telength property is an accessor property whose set accessor function is undefined, meaning that you can only read this property.
... examples using by
telength var sab = new sharedarraybuffer(1024); sab.by
telength; // 1024 specifications specification ecmascript (ecma-262)the definition of 'sharedarraybuffer.prototype.by
telength' in that specification.
TypedArray.prototype.byteLength - JavaScript
the by
telength accessor property represents the length (in bytes) of a typed array.
... description the by
telength property is an accessor property whose set accessor function is undefined, meaning that you can only read this property.
... examples using the by
telength property var buffer = new arraybuffer(8); var uint8 = new uint8array(buffer); uint8.by
telength; // 8 (matches the by
telength of the buffer) var uint8 = new uint8array(buffer, 1, 5); uint8.by
telength; // 5 (as specified when constructing the uint8array) var uint8 = new uint8array(buffer, 2); uint8.by
telength; // 6 (due to the offset of the constructed uint8array) specifications specification ecmascript (ecma-262)the definition of 'typedarray.prototype.by
telength' in that specification.
HTMLFontElement.color - Web APIs
the obsolete htmlfon
telement.color property is a domstring that reflects the color html attribute, containing either a named color or a color specified in the hexadecimal #rrggbb format.
...ame color string nameofcolor (case insensitive) green green green valid hex color string in rgb format: #rrggbb #008000 rgb using decimal values rgb(x,x,x) (x in 0-255 range) rgb(0,128,0) syntax colorstring = fontobj.color; fontobj.color = colorstring; examples // assumes there is <font id="f"> element in the html var f = document.ge
telementbyid("f"); f.color = "green"; specifications the <font> tag is not supported in html5 and as a result neither is <font>.color.
HTMLFontElement.face - Web APIs
the obsolete htmlfon
telement.face property is a domstring that reflects the face html attribute, containing a comma-separated list of one or more font names.
...must follow one of the following html microsyntax: microsyntax description examples list of one or more valid font family names a list of font names, that have to be present on the local system courier,verdana syntax facestring = fontobj.face; fontobj.face = facestring; examples // assumes there is <font id="f"> element in the html var f = document.ge
telementbyid("f"); f.face = "arial"; specifications the <font> tag is not supported in html5 and as a result neither is <font>.face .
HTMLFontElement.size - Web APIs
the obsolete htmlfon
telement.size property is a domstring that reflects the size html attribute.
... integer number in the range of 1-7 6 relative size string +x or -x, where x is the number relative to the value of the size attribute of the <basefont> element (the result should be in the same range of 1-7) +2 -1 syntax sizestring = fontobj.size; fontobj.size = sizestring; examples // assumes there is <font id="f"> element in the html var f = document.ge
telementbyid("f"); f.size = "6"; specifications the <font> tag is not supported in html5 and as a result neither is <font>.size .
HTMLInputElement.labels - Web APIs
the htmlinpu
telement.labels read-only property returns a nodelist of the <label> elements associated with the <input> element.
... example html <label id="label1" for="test">label 1</label> <input id="test"/> <label id="label2" for="test">label 2</label> javascript window.addeventlistener("domcontentloaded", function() { const input = document.ge
telementbyid("test"); for(var i = 0; i < input.labels.length; i++) { console.log(input.labels[i].textcontent); // "label 1" and "label 2" } }); specifications specification status comment html living standardthe definition of 'labels' in that specification.
HTMLInputElement.multiple - Web APIs
the htmlinpu
telement.multiple property indicates if an input can have more than one value.
... example // fileinput is a <input type=file multiple> let fileinput = document.ge
telementbyid('myfileinput'); if (fileinput.multiple == true) { for (let i = 0; i < fileinput.files.length; i++) { // loop fileinput.files } // only one file available } else { let file = fileinput.files.item(0); } ...
HTMLInputElement.stepUp() - Web APIs
the htmlinpu
telement.stepup() method increments the value of a numeric type of <input> element by the value of the step attribute, or the default step value if the step attribute is not explicitly set.
... by 5: <input type="number" step="5" id="thenumber" min="0" max="400"> </label> </p> <p> <label>enter how many values of step you would like to increment by or leave it blank: <input type="number" step="1" id="incrementer" min="0" max="25"> </label> </p> <input type="button" value="increment" id="thebutton"> javascript /* make the button call the function */ let button = document.ge
telementbyid('thebutton') button.addeventlistener('click', function() { steponup() }) function steponup() { let input = document.ge
telementbyid('thenumber') let val = document.ge
telementbyid('incrementer').value if (val) { /* increment with a parameter */ input.stepup(val) } else { /* or without a parameter.
HTMLObjectElement.checkValidity - Web APIs
the checkvalidity() method of the htmlobjec
telement interface returns a boolean that always is true, because object objects are never candidates for constraint validation.
... syntax const valid = htmlobjec
telement.checkvalidity(); parameters none.
HTMLObjectElement.contentDocument - Web APIs
the contentdocument read-only property of the htmlobjec
telement interface returns a document representing the active document of the object element's nested browsing context, if any; otherwise null.
... syntax var document = htmlobjec
telement.contentdocument; value a document.
HTMLObjectElement.contentWindow - Web APIs
the contentwindow read-only property of the htmlobjec
telement interface returns a windowproxy representing the window proxy of the object element's nested browsing context, if any; otherwise null.
... syntax var windowproxy = htmlobjec
telement.contentwindow; value a windowproxy.
HTMLObjectElement.data - Web APIs
the data property of the htmlobjec
telement interface returns a domstring that reflects the data html attribute, specifying the address of a resource's data.
... syntax var data = htmlobjec
telement.data; htmlobjec
telement.data; value a domstring.
HTMLObjectElement.form - Web APIs
the form read-only property of the htmlobjec
telement interface retuns a htmlformelement representing the object element's form owner, or null if there isn't one.
... syntax var htmlformelement = htmlobjec
telement.form; value a htmlformelement.
HTMLObjectElement.height - Web APIs
the height property of the htmlobjec
telement interface returns a domstring that reflects the height html attribute, specifying the displayed height of the resource in css pixels.
... syntax var string = htmlobjec
telement.height; htmlobjec
telement.height = string; value a domstring.
HTMLObjectElement.name - Web APIs
the name property of the htmlobjec
telement interface returns a domstring that reflects the name html attribute, specifying the name of the browsing context.
... syntax var string = htmlobjec
telement.name; htmlobjec
telement.name = string; value a domstring.
HTMLObjectElement.type - Web APIs
the type property of the htmlobjec
telement interface returns a domstring that reflects the type html attribute, specifying the mime type of the resource.
... syntax var string = htmlobjec
telement.type htmlobjec
telement.type = string; value a domstring.
HTMLObjectElement.useMap - Web APIs
the usemap property of the htmlobjec
telement interface returns a domstring that reflects the usemap html attribute, specifying a <map> element to use.
... syntax var string = htmlobjec
telement.usemap; htmlobjec
telement.usemap = string; value a domstring.
HTMLObjectElement.validationMessage - Web APIs
the validationmessage read-only property of the htmlobjec
telement interface returns a domstring representing a localized message that describes the validation constraints that the control does not satisfy (if any).
... syntax var string = htmlobjec
telement.validationmessage; value a domstring.
HTMLObjectElement.validity - Web APIs
the validity read-only property of the htmlobjec
telement interface returns a validitystate with the validity states that this element is in.
... syntax var validitystate = htmlobjec
telement.validity; value a validitystate object.
Applying styles and colors - Web APIs
function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); for (var i = 0; i < 6; i++) { for (var j = 0; j < 6; j++) { ctx.fillstyle = 'rgb(' + math.floor(255 - 42.5 * i) + ', ' + math.floor(255 - 42.5 * j) + ', 0)'; ctx.fillrect(j * 25, i * 25, 25, 25); } } } <canvas id="canvas" width="150" height="150"></canvas> draw(); the result looks like this: screenshotlive s...
... function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); for (var i = 0; i < 6; i++) { for (var j = 0; j < 6; j++) { ctx.strokestyle = 'rgb(0, ' + math.floor(255 - 42.5 * i) + ', ' + math.floor(255 - 42.5 * j) + ')'; ctx.beginpath(); ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, math.pi * 2, true); ctx.stroke(); } } } <canvas id="canvas" width="150" height="150"></canvas> draw(); the result looks like this: screenshotlive sample transparency in addition to drawing opaqu...
...by increasing the step count and in effect drawing more circles, the background would comple
tely disappear from the center of the image.
...And 20 more matches
Multiple-column layout - Learn web development
cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
... curabitur vehicula
tellus neque, ac ornare ex malesuada et.
...cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...And 19 more matches
Index - MDN Web Docs Glossary: Definitions of Web-related terms
in vector images, they are used to model smooth curves that can be scaled indefini
tely.
...not all http responses can be cached, these are the following constraints for an http response to be cached: 61 caldav caldav, glossary, infrastructure caldav (calendaring extensions to webdav) is a protocol standardized by the ietf and used to remo
tely access calendar data from a server.
...these
tell a computer/software program what to do in a language which the computer understands.
...And 18 more matches
Introduction to CSS layout - Learn web development
cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...curabitur vehicula
tellus neque, ac ornare ex malesuada et.
... absolute positioning moves an element comple
tely out of the page's normal layout flow, like it is sitting on its own separate layer.
...And 17 more matches
Floats - Learn web development
cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...curabitur vehicula
tellus neque, ac ornare ex malesuada et.
...cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...And 14 more matches
Power profiling overview
this article covers important background information about power profiling, with an emphasis on in
tel processors used in desktop and laptop machines.
... in
tel processor basics processor layout the following diagram (from the in
tel power governor documentation) shows how machines using recent in
tel processors are constructed.
...these are part of the actual processor that you buy from in
tel.
...And 14 more matches
TypeScript support in Svelte - Learn web development
note that our application is fully functional and porting it to typescript is comple
tely optional.
... repl unfortuna
tely, typescript support is not yet available in the repl.
... steep learning curve: even though typescript is a superset of javascript and not a comple
tely new language, there is a considerable learning curve, especially if you have no experience at all with static languages like java or c#.
...And 13 more matches
An Interview With Douglas Bowman of Wired News - Archive of obsolete content
the content of the site
tells the story of how technology affects our daily lives, especially in the realms of business, culture, and politics.
...i think that fact played a critical role in our team's willingness to try out something comple
tely new.
... our engineering team actually needed the least convincing to convert over to a standards-based design, because they could also immedia
tely envision the benefits to their workload and maintenance of the site.
...And 12 more matches
Index
many (if not most) of the operations performed by nss involve the use of x.509 certificates (often abbreviated as “cert”, unfortuna
tely making it easy to confuse with the term “computer emergency response team“).
...a trust anchor is just another x.509 certificate that is already known and has been delibera
tely marked as trusted by a software vendor, administrators inside an organizational infrastructure, or the software user.
... because of nss's expectation to operate with an nss database, it's mandatory that you perform an initialization call, where you
tell nss which database you will be using.
...And 12 more matches
JIT Optimization Strategies
optimization information is currently collected for the following operations: getproperty (obj.prop) setproperty (obj.prop = val) ge
telement (obj[elemname]) se
telement (obj[elemname] = val) call (func(...)) at each operation site, ionmonkey tries a battery of strategies, from the most optimized but most restrictive to the least optimized but least restrictive.
... ge
telement ge
telem_typedobject attempts to optimized element accesses on array typed objects.
... ge
telem_dense attempts to optimize element accesses on densely packed array objects.
...And 12 more matches
window.location - Web APIs
example #6: using bookmarks without changing the hash property: <!doctype html> <html> <head> <meta charset="utf-8"/> <title>mdn example</title> <script> function shownode (onode) { document.documen
telement.scrolltop = onode.offsettop; document.documen
telement.scrollleft = onode.offsetleft; } function showbookmark (sbookmark, busehash) { if (arguments.length === 1 || busehash) { location.hash = sbookmark; return; } var obookmark = document.queryselector(sbookmark); if (obookmark) { shownode(obookmark); } } </script> <style> span.intlink { cursor: pointer; color: #0000ff; te...
...quisque in ante
tellus, in placerat est.
...etiam congue, elit vitae egestas mollis, ipsum nisi malesuada turpis, a volutpat arcu arcu id risus.</p> <p>nam faucibus, ligula eu fringilla pulvinar, lectus
tellus iaculis nunc, vitae scelerisque metus leo non metus.
...And 12 more matches
sslfnc.html
ssl_enable_fdx
tells the ssl library whether the application will have two threads, one reading and one writing, or just one thread doing reads and writes alterna
tely.
... ssl_v2_compatible_hello
tells the ssl library whether or not to send ssl3 client hello messages in ssl2-compatible format.
... the ssl_enable_fdx option
tells the ssl library whether the application will have two threads, one reading and one writing, or just one thread doing reads and writes alterna
tely.
...And 11 more matches
Extension Versioning, Update and Compatibility - Archive of obsolete content
overriding compatibility checking for testing purposes you can
tell the application to somewhat ignore compatibility checks when installing add-ons.
...the * actually represents an infini
tely high number and so is really only sensibly used in the maxversion.
...ication the add-on is compatible with --> <em:targetapplication> <rdf:description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minversion>1.5</em:minversion> <em:maxversion>2.0.0.*</em:maxversion> <!-- this is where this version of the add-on will be downloaded from --> <em:upda
telink>https://www.mysite.com/foobar2.2.xpi</em:upda
telink> <!-- a page describing what is new in this updated version --> <em:updateinfourl>http://www.mysite.com/updateinfo2.2.xhtml</em:updateinfourl> </rdf:description> </em:targetapplication> </rdf:description> </rdf:li> <rdf:li> <rdf:description> ...
...And 10 more matches
Positioning - Learn web development
an absolu
tely positioned element no longer exists in the normal document layout flow.
...so in this case, we are saying that the absolu
tely positioned element should sit 30px from the top of the "containing element", and 30px from the left.
... positioning contexts which element is the "containing element" of an absolu
tely positioned element?
...And 10 more matches
Index
any time a new value is assigned into an nscomptr, the nscomptr automatically always releases its old referent, if any, and (unless you
tell it you already have) addrefs the new.
...the following four sections
tell the developer how to download and organize the gecko sdk and create a new project in which components like weblock can be created.
...however, with decode-on-draw, the set of decode notifications can come comple
tely after the load notifications, and can come multiple times if the image is discardable.
...And 10 more matches
Key Values - Web APIs
(also known as suspend or sleep.) this turns off the display and puts the computer in a low power consumption mode, without comple
tely powering off.
... tv control keys these key values represent buttons or keys present on
television devices, or computers or phones which have tv support.
... keycode_tv_radio_service (232) "tvsa
tellite" sa
tellite button.
...And 10 more matches
Color picker tool - CSS: Cascading Style Sheets
16px; position: absolute; opacity: 0; top: -10000px; left: 0; color: #777; float: left; transition: opacity 1s; } #zindex input { border: 1px solid #ddd; font-size: 16px; color: #777; } #zindex .ui-input-slider-info { width: 60px; } #zindex[data-active='true'] { top: 0; opacity: 1; } javascript content 'use strict'; var uicolorpicker = (function uicolorpicker() { function ge
telembyid(id) { return document.ge
telementbyid(id); } var subscribers = []; var pickers = []; /** * rgba color class * * hsv/hsb and hsl (hue, saturation, value / brightness, lightness) * @param hue 0-360 * @param saturation 0-100 * @param value 0-100 * @param lightness 0-100 */ function color(color) { if(color instanceof color === true) { this.copy(color); ret...
...ue, subscribe : subscribe, unsubscribe : unsubscribe, setprecision : setprecision, setsensivity : setsensivity, getprecision : getprecision, createslider : createslider, }; })(); 'use strict'; window.addeventlistener("load", function() { colorpickertool.init(); }); var colorpickertool = (function colorpickertool() { /*========== get dom element by id ==========*/ function ge
telembyid(id) { return document.ge
telementbyid(id); } function allowdropevent(e) { e.preventdefault(); } /*========== make an element resizable relative to it's parent ==========*/ var uicomponent = (function uicomponent() { function makeresizable(elem, axis) { var valuex = 0; var valuey = 0; var action = 0; var resizestart = function resizestart(e) { e.stoppropagation...
....prototype.updatesaturation = function updatesaturation(color, value, steps) { var saturation = color.saturation + value * steps; if (saturation <= 0) { this.node.setattribute('data-hidden', 'true'); return; } this.node.removeattribute('data-hidden'); this.color.copy(color); this.color.setsaturation(saturation); this.updatebgcolor(); }; colorsample.prototype.upda
telightness = function upda
telightness(color, value, steps) { var lightness = color.lightness + value * steps; if (lightness <= 0) { this.node.setattribute('data-hidden', 'true'); return; } this.node.removeattribute('data-hidden'); this.color.copy(color); this.color.setlightness(lightness); this.updatebgcolor(); }; colorsample.prototype.updatebrightness = function up...
...And 10 more matches
widget - Archive of obsolete content
next, we write a content script that listens for click events on each icon and sends the corresponding message to the main add-on code: var play_button = document.ge
telementbyid("play-button"); play_button.onclick = function() { self.port.emit("play"); } var pause_button = document.ge
telementbyid("pause-button"); pause_button.onclick = function() { self.port.emit("pause"); } var stop_button = document.ge
telementbyid("stop-button"); stop_button.onclick = function() { self.port.emit("stop"); } we save this file in the add-on's data directory as "button-sc...
... first, in the content script, change self to addon, and wrap it in a function: function init() { var play_button = document.ge
telementbyid("play-button"); play_button.onclick = function() { addon.port.emit("play"); } var pause_button = document.ge
telementbyid("pause-button"); pause_button.onclick = function() { addon.port.emit("pause"); } var stop_button = document.ge
telementbyid("stop-button"); stop_button.onclick = function() { addon.port.emit("stop"); } } next, add a script tag to reference...
...the widget is immedia
tely added to the add-on bar.
...And 9 more matches
jspage - Archive of obsolete content
c;}return b;}var browser=$merge({engine:{name:"unknown",version:0},platform:{name:(window.orientation!=undefined)?"ipod":(navigator.platform.match(/mac|win|linux/i)||["other"])[0].tolowercase()},features:{xpath:!!(document.evaluate),air:!!(window.runtime),query:!!(document.queryselector)},plugins:{},engines:{presto:function(){return(!window.opera)?false:((arguments.callee.caller)?960:((document.ge
telementsbyclassname)?950:925)); },trident:function(){return(!window.activexobject)?false:((window.xmlhttprequest)?((document.queryselectorall)?6:5):4);},webkit:function(){return(navigator.taintenabled)?false:((browser.features.xpath)?((browser.features.query)?525:420):419); },gecko:function(){return(!document.getboxobjectfor&&window.mozinnerscreenx==null)?false:((document.ge
telementsbyclassname)?19:...
...ment.prototype=(browser.engine.webkit)?window["[[domelement.prototype]]"]:{}; }a.document.window=a;return $extend(a,window.prototype);},afterimplement:function(b,a){window[b]=window.prototype[b]=a;}});window.prototype={$family:{name:"window"}}; new window(window);var document=new native({name:"document",legacy:(browser.engine.trident)?null:window.document,initialize:function(a){$uid(a);a.head=a.ge
telementsbytagname("head")[0]; a.html=a.ge
telementsbytagname("html")[0];if(browser.engine.trident&&browser.engine.version<=4){$try(function(){a.execcommand("backgroundimagecache",false,true); });}if(browser.engine.trident){a.window.attachevent("onunload",function(){a.window.detachevent("onunload",arguments.callee);a.head=a.html=a.window=null; });}return $extend(a,document.prototype);},afterimplement:...
...{if(browser.engine.trident&&b){["name","type","checked"].each(function(c){if(!b[c]){return;}a+=" "+c+'="'+b[c]+'"'; if(c!="checked"){delete b[c];}});a="<"+a+">";}return document.id(this.createelement(a)).set(b);},newtextnode:function(a){return this.createtextnode(a); },getdocument:function(){return this;},getwindow:function(){return this.window;},id:(function(){var a={string:function(d,c,b){d=b.ge
telementbyid(d);return(d)?a.element(d,c):null; },element:function(b,e){$uid(b);if(!e&&!b.$family&&!(/^object|embed$/i).test(b.tagname)){var c=element.prototype;for(var d in c){b[d]=c[d];}}return b;},object:function(c,d,b){if(c.toelement){return a.element(c.toelement(b),d); }return null;}};a.textnode=a.whitespace=a.window=a.document=$arguments(0);return function(c,e,d){if(c&&c.$family&&c.uid){return c...
...And 9 more matches
Fundamental text and font styling - Learn web development
the css properties used to style text generally fall into two categories, which we'll look at separa
tely in this article: font styles: properties that affect the font that is applied to the text, affecting what font is applied, how big it is, whether it is bold, italic, etc.
...truly a wonder of nature this urban predator — tommy the cat had many a story to
tell.
...truly a wonder of nature this urban predator — tommy the cat had many a story to
tell.
...And 9 more matches
Advanced Svelte: Reactivity, lifecycle, accessibility - Learn web development
remember that to
tell svelte that a variable has changed, you have to assign it a new value.
...that's because svelte can't track object references, so we have to explicitly
tell it that obj has changed by issuing an assignment.
... note: if foo is a top level variable, you can easily
tell svelte to update obj whenever foo is changed with the following reactive statement: $: foo, obj = obj.
...And 9 more matches
DMD
for instance, on osx, you can run something like: dmd=1 /applications/firefox\ nightly.app/contents/macos/firefox you can
tell it is working by going to about:memory and looking for "save dmd output".
... if you see the "opened" line, it
tells you where the file was saved.
...this
tells you how dmd was invoked, i.e.
...And 9 more matches
Signaling and video calling - Web APIs
note: if you try out the example on glitch, please note that any changes made to the code will immedia
tely reset any connections.
... note: the onicecandidate event and createanswer() promise are both async calls which are handled separa
tely.
...we specify the autoplay attribute, ensuring once the video starts arriving, it immedia
tely plays.
...And 9 more matches
Enhanced Extension Installation - Archive of obsolete content
when changes are made to the extensions datasource - new items are installed, old items uninstalled, enabled or disabled, a .autoreg file is written to the profile directory as well, which
tells the startup code that the system has been modified, so that it destroys the component registries, finishes pending transactions and regenerates metadata appropria
tely.
...if it is, a small set of metadata about it is written to the appropriate datasource (name, version, a flag to
tell the system to properly install it on the next startup), and it is added to the appropriate type container.
... the system also writes a .autoreg file to the profile folder which
tells the startup system that something has changed on the next restart.
...And 8 more matches
JXON - Archive of obsolete content
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html |*| \*/ function createxml (oobjtree) { function loadobjtree (oparen
tel, oparentobj) { var vvalue, ochild; if (oparentobj.constructor === string || oparentobj.constructor === number || oparentobj.constructor === boolean) { oparen
tel.appendchild(onewdoc.createtextnode(oparentobj.tostring())); /* verbosity level is 0 or 1 */ if (oparentobj === oparentobj.valueof()) { return; } } else if (oparentobj.constructor === date) { oparen
tel.appendc...
...hild(onewdoc.createtextnode(oparentobj.togmtstring())); } for (var sname in oparentobj) { if (isfinite(sname)) { continue; } /* verbosity level is 0 */ vvalue = oparentobj[sname]; if (sname === "keyvalue") { if (vvalue !== null && vvalue !== true) { oparen
tel.appendchild(onewdoc.createtextnode(vvalue.constructor === date ?
... vvalue.togmtstring() : string(vvalue))); } } else if (sname === "keyattributes") { /* verbosity level is 3 */ for (var sattrib in vvalue) { oparen
tel.setattribute(sattrib, vvalue[sattrib]); } } else if (sname.charat(0) === "@") { oparen
tel.setattribute(sname.slice(1), vvalue); } else if (vvalue.constructor === array) { for (var nitem = 0; nitem < vvalue.length; nitem++) { ochild = onewdoc.createelement(sname); loadobjtree(ochild, vvalue[nitem]); oparen
tel.appendchild(ochild); } } else { ochild = onewdoc.createelement(sname); if (vvalue instanceof object) { loadobjtree(ochild, vvalue); } else if (vvalue !== null && vvalue !== true) { ochild.appendchild(onewdoc.crea...
...And 8 more matches
WAI-ARIA basics - Learn web development
if you are looking for a 3rd party javascript solution for rapid ui development, you should defini
tely consider the accessibility of its ui widgets as an important factor when making your choice.
...ideally, you should always use native html features to provide the semantics required by screenreaders to
tell their users what is going on.
...and if for some reason your site is built using just <div>s, you should defini
tely include the aria roles to provide these much needed semantics!
...And 8 more matches
A first splash into JavaScript - Learn web development
previous overview: first steps next now you've learned something about the theory of javascript, and what you can do with it, we are going to give you a crash course in the basic features of javascript via a comple
tely practical tutorial.
... you won't be expected to understand all of the code in detail immedia
tely — we just want to introduce you to the high-level concepts for now, and give you an idea of how javascript (and other programming languages) work.
...we'll
tell you if your guess was too high or too low.</p> <div class="form"> <label for="guessfield">enter a guess: </label><input type="text" id="guessfield" class="guessfield"> <input type="submit" value="submit guess" class="guesssubmit"> </div> <div class="resultparas"> <p class="guesses"></p> <p class="lastresult"></p> <p class="loworhi"></p> </div> <script> // ...
...And 8 more matches
Observer Notifications
profile-before-change-
telemetry called to shut down
telemetry, again separated to allow everything before this event to continue using it.
... topic subject data description chrome-document-global-created nsidomwindow null sent immedia
tely after a chrome document window has been set up, but before any script code has been executed.
... content-document-global-created nsidomwindow origin sent immedia
tely after a web content document window has been set up, but before any script code has been executed.
...And 8 more matches
Drawing shapes with canvas - Web APIs
rectangular shape example <html> <body onload="draw();"> <canvas id="canvas" width="150" height="150"></canvas> </body> </html> function draw() { var canvas = document.ge
telementbyid('canvas'); if (canvas.getcontext) { var ctx = canvas.getcontext('2d'); ctx.fillrect(25, 25, 100, 100); ctx.clearrect(45, 45, 60, 60); ctx.strokerect(50, 50, 50, 50); } } this example's output is shown below.
... unlike the path functions we'll see in the next section, all three rectangle functions draw immedia
tely to the canvas.
... note: when the current path is empty, such as immedia
tely after calling beginpath(), or on a newly created canvas, the first path construction command is always treated as a moveto(), regardless of what it actually is.
...And 8 more matches
Document - Web APIs
document.documen
telementread only returns the element that is a direct child of the document.
... parentnode.firs
telementchild read only returns the first node which is both a child of this parentnode and is also an element, or null if there is none.
... parentnode.las
telementchild read only returns the last node which is both a child of this parentnode and is an element, or null if there is none.
...And 8 more matches
PerformanceResourceTiming - Web APIs
performanceresourcetiming.workerstartread only returns a domhighrestimestamp immedia
tely before dispatching the fetchevent if a service worker thread is already running, or immedia
tely before starting the service worker thread if it is not already running.
... performanceresourcetiming.redirectendread only a domhighrestimestamp immedia
tely after receiving the last byte of the response of the last redirect.
... performanceresourcetiming.fetchstartread only a domhighrestimestamp immedia
tely before the browser starts to fetch the resource.
...And 8 more matches
Implementing a Microsoft Active Accessibility (MSAA) Server - Accessibility
unfortuna
tely, some products can get confused by the vertical lines on other objects, such as list boxes, even though those lines are not blinking.
...even if you are visibly showing window focus on the correct window, you must also
tell the operating system to focus this window before any other accessibility events get fired in it.
...these can be problematic, because the assistive technology has no way to
tell whether the event came from your application or from windows.
...And 8 more matches
Cross-browser audio basics - Developer guides
</audio> you can grab the <audio> element like this: var myaudio = document.ge
telementbyid('my-audio'); alternatively, you can create a new element.
... play the play() method is used to
tell the audio to play.
... myaudio.play(); pause the pause() method is used to
tell the audio to pause.
...And 8 more matches
Namespaces crash course - SVG: Scalable Vector Graphics
versions of svg viewers prior to the release of firefox 1.5 unfortuna
tely paid scant attention to namespaces, but they are essential to multi-xml dialect supporting user agents such as gecko-based browsers which must be very strict.
...in fact how does the user agent
tell when xml content is something it knows about, and not just a meaningless xml file containing arbitrary element names unknown to it?
... contrary to popular opinion, the answer to this question is not "it can
tell from the doctype declaration".
...And 8 more matches
From object to iframe — other embedding technologies - Learn web development
active learning: classic embedding uses in this article we are going to jump straight into an active learning section, to immedia
tely give you a real idea of just what embedding technologies are useful for.
...t: 100px;"> </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); const output = document.queryselector('.output'); let code = textarea.value; let userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; sol...
...> <a href="https://udn.realityripple.com/docs/glossary"> fallback link for browsers that don't support iframes </a> </p> </iframe> this example includes the basic essentials needed to use an <iframe>: allowfullscreen if set, the <iframe> is able to be placed in fullscreen mode using the full screen api (somewhat beyond scope for this article.) frameborder if set to 1, this
tells the browser to draw a border between this frame and other frames, which is the default behaviour.
...And 7 more matches
Using images - Web APIs
using images from the same page we can obtain a reference to images on the same page as the canvas by using one of: the document.images collection the document.ge
telementsbytagname() method if you know the id of the specific image you wish to use, you can use document.ge
telementbyid() to retrieve that specific image using images from other domains using the crossorigin attribute of an <img> element (reflected by the htmlimageelement.crossorigin property), you can request permission to load an image from another domain for use in your call to drawimage().
... using other canvas elements just as with normal images, we access other canvas elements using either the document.ge
telementsbytagname() or document.ge
telementbyid() method.
...data urls allow you to comple
tely define an image as a base64 encoded string of characters directly in your code.
...And 7 more matches
Traversing an HTML table with JavaScript and DOM Interfaces - Web APIs
example: creating an html table dynamically (sample1.html) html <input type="button" value="generate a table." onclick="generate_table()"> javascript function generate_table() { // get the reference for the body var body = document.ge
telementsbytagname("body")[0]; // creates a <table> element and a <tbody> element var tbl = document.createelement("table"); var tblbody = document.createelement("tbody"); // creating all cells for (var i = 0; i < 2; i++) { // creates a table row var row = document.createelement("tr"); for (var j = 0; j < 2; j++) { // create a <td> element and a text node, make the text...
... example: setting the background color of a paragraph ge
telementsbytagname(tagnamevalue) is a method available in any dom element or the root document element.
... html <body> <input type="button" value="set paragraph background color" onclick="set_background()"> <p>hi</p> <p>hello</p> </body> javascript function set_background() { // get a list of all the body elements (there will only be one), // and then select the zeroth (or first) such element mybody = document.ge
telementsbytagname("body")[0]; // now, get all the p elements that are descendants of the body mybodyelements = mybody.ge
telementsbytagname("p"); // get the second item of the list of p elements myp = mybodyelements[1]; myp.style.background = "rgb(255,0,0)"; } in this example, we set the myp variable to the dom object for the second p element inside the body: first, we get a list of...
...And 7 more matches
Box-shadow generator - CSS: Cascading Style Sheets
= function init() { var elem = document.queryselectorall('.ui-checkbox'); var size = elem.length; for (var i = 0; i < size; i++) new checkbox(elem[i]); } return { init : init, setvalue : setvalue, subscribe : subscribe, unsubscribe : unsubscribe } })(); window.addeventlistener("load", function(){ boxshadow.init(); }); var boxshadow = (function boxshadow() { function ge
telembyid(id) { return document.ge
telementbyid(id); } /** * rgba color class */ function color() { this.r = 0; this.g = 0; this.b = 0; this.a = 1; this.hue = 0; this.saturation = 0; this.value = 0; } color.prototype.copy = function copy(obj) { if(obj instanceof color !== true) { console.log("typeof instance not color"); return; } this.r = obj.r; this.g = obj...
...ibers[topic] === undefined) subscribers[topic] = []; subscribers[topic].push(callback); } var unsubscribe = function unsubscribe(callback) { subscribers.indexof(callback); subscribers.splice(index, 1); } var notify = function notify(topic, value) { for (var i in subscribers[topic]) subscribers[topic][i](value); } var init = function init() { colorpicker = ge
telembyid("colorpicker"); hue_area = ge
telembyid("hue"); gradient_area = ge
telembyid("gradient"); alpha_area = ge
telembyid("alpha"); gradient_picker = ge
telembyid("gradient_picker"); hue_selector = ge
telembyid("hue_selector"); alpha_selector = ge
telembyid("alpha_selector"); output_color = ge
telembyid("output_color"); var elem = document.queryselectorall('#colorpicker .input...
...hue_area, updatehue); setmousetracking(alpha_area, updatealpha); } return { init : init, setcolor : setcolor, subscribe : subscribe, unsubscribe : unsubscribe } })(); /** * shadow dragging */ var previewmousetracking = (function drag() { var active = false; var lastx = 0; var lasty = 0; var subscribers = []; var init = function init(id) { var elem = ge
telembyid(id); elem.addeventlistener('mousedown', dragstart, false); document.addeventlistener('mouseup', dragend, false); } var dragstart = function dragstart(e) { if (e.button !== 0) return; active = true; lastx = e.clientx; lasty = e.clienty; document.addeventlistener('mousemove', mousedrag, false); } var dragend = function dragend(e) { if (e.button !== 0) ...
...And 7 more matches
position - CSS: Cascading Style Sheets
the margins of absolu
tely positioned boxes do not collapse with other margins.
... an absolu
tely positioned element is an element whose computed position value is absolute or fixed.
... most of the time, absolu
tely positioned elements that have height and width set to auto are sized so as to fit their contents.
...And 7 more matches
Media buffering, seeking, and time ranges - Developer guides
buffered the buffered attribute will
tell us which parts of the media has been downloaded.
... it returns a timeranges object, which will
tell us which chunks of media have been downloaded.
... this will work with <audio> or <video>; for now let's consider a simple audio example: <audio id="my-audio" controls src="music.mp3"> </audio> we can access these attributes like so: var myaudio = document.ge
telementbyid('my-audio'); var bufferedtimeranges = myaudio.buffered; timeranges object timeranges are a series of non-overlapping ranges of time, with start and stop times.
...And 7 more matches
Web audio codec guide - Web media technologies
additionally, webrtc implementations generally use a subset of these codecs for their encoding and decoding of media, and may support additional codecs as well, for optimal cross-platform support of video and audio conferencing, and to integrate better with legacy
telecommunication solutions.
...c name container support aac advanced audio coding mp4, adts, 3gp alac apple lossless audio codec mp4, quicktime (mov) amr adaptive multi-rate 3gp flac free lossless audio codec mp4, ogg, flac g.711 pulse code modulation (pcm) of voice frequencies rtp / webrtc g.722 7 khz audio coding within 64 kbps (for
telephony/voip) rtp / webrtc mp3 mpeg-1 audio layer iii mp4, adts, mpeg1, 3gp opus opus webm, mp4, ogg vorbis vorbis webm, ogg [1] when mpeg-1 audio layer iii codec data is stored in an mpeg file, and there is no video track on the file, the file is typically referred to as an mp3 file, even though it's still an mpeg format file.
...it was standardized in 1999 as part of the 3gpp audio standard used for both gsm and umts cellular
telephony, and uses a multi-rate narrowband algorithm to encode audio frequencies at a
telephony-grade quality level at around 7.4 kbps.
...And 7 more matches
page-mod - Archive of obsolete content
/lib/main.js: var tag = "p"; var data = require("sdk/self").data; var pagemod = require("sdk/page-mod"); pagemod.pagemod({ include: "*.mozilla.org", contentscriptfile: data.url("element-getter.js"), onattach: function(worker) { worker.port.emit("ge
telements", tag); worker.port.on("go
telement", function(elementcontent) { console.log(elementcontent); }); } }); /data/element-getter.js: self.port.on("ge
telements", function(tag) { var elements = document.ge
telementsbytagname(tag); for (var i = 0; i < elements.length; i++) { self.port.emit("go
telement", elements[i].innerhtml); } }); when the user loads a document hosted ...
...it adds a listener to the ge
telements message.
...its event handler sends the ge
telements message to the content script, and then adds a listener to the go
telement message.
...And 6 more matches
Inner-browsing extending the browser navigation paradigm - Archive of obsolete content
note that the ticker is a comple
tely separated component.
...note the following piece of code: function iframecallback(doc) { /* copies the data in the iframe to the main page */ mydata = doc.ge
telementbyid("mydata"); tickerdiv.innerhtml = mydata.innerhtml; } the callback is called with the parameter doc, which is a reference to the iframe's document).
...the following code snippet shows a simplified version of the logic that happens in the actual sample: // doc is the dom to the document returned articles=doc.ge
telementsbytagname("article"); for(i=0;i<articles.length;i++) { // acquiring the data from the dom...
...And 6 more matches
MCD, Mission Control Desktop, AKA AutoConfig - Archive of obsolete content
it's mission is to enable comple
tely automatic configuration of mozilla's apps preferences based on users properties either retrieved from system environement variables or on an organisation ldap directory.
...// pref("general.config.obscure_value", 0); // for mcd .cfg files pref('general.config.filename', 'thunderbird.cfg'); // for mcd .cfg files it used to be in previous releases (up until 7.0) in /usr/lib/thunderbird-x.0/default/pref/autoconf.js the first pref just
tells us that we won't encode the file (no more rotary 13 or 7 cf below), the second pref is the name of the file to be read: /usr/lib/thunderbird/thunderbird.cfg.
...please see //(german) http://interop.blog.de/2010/02/13/kapi
tel-1-ldap-anfragen-linux-ad-8001564/ //or search the net how to do it.
...And 6 more matches
Introduction to XUL - Archive of obsolete content
though the former term seems more concrete than the other, and therefore is not an exact replacement, no one is comple
tely certain why we have both.
... mozilla applications will be built of "small" components like dialog buttons and mail inbox folders, which we collectively term "widgets." within a widget, drawing and user interactions are comple
tely under control of the individual widget, and set when the widget was built.
... <html:script type="application/javascript"> // dialog initialization code function initwindow() { var checkbox = document.ge
telementbyid("remember"); if (checkbox) checkbox.checked = true; } </html:script> javascript can be referenced as in html documents: as onclick handlers and the like.
...And 6 more matches
Browser Detection and Cross Browser Support - Archive of obsolete content
unfortuna
tely, no other browser supports web standards as comple
tely as gecko.
...fortuna
tely, other browsers such as opera (versions 7 & later) and to a lesser extent, internet explorer (versions 5.5 & later) also support the standards to a degree.
...unfortuna
tely, the netscape 6 user agent string was not sufficiently generalizable due to it's use of the string netscape6 as a description of the vendor.
...And 6 more matches
Browser Feature Detection - Archive of obsolete content
00% 100% 100% / 100% 96% / 96% dom css 2 100% 98% 67% 71% / 83% 38% / 42% test results cross reference dom core level 1 support for properties/methods in document name firefox 1.5 ie 6 & 7 opera 8.54 - 9.01 document.doctype true true true document.implementation true true true document.documen
telement true true true document.createelement() true true true document.createdocumentfragment() true true true document.createtextnode() true true true document.createcomment() true true true document.createcdatasection() true false true document.createprocessinginstruction() true false...
... true document.createattribute() true true true document.createentityreference()obsolete since gecko 7 (method present but only returns null: bug 9850) false false document.ge
telementsbytagname() true true true dom core level 2 support for properties/methods in document name firefox 1.5 ie 6 & 7 opera 8.54 - 9.01 document.doctype true true true document.implementation true true true document.documen
telement true true true document.createelement() true true true document.createdocumentfragment() true true true document.createtextnode() true true true document.createcomment() true true tr...
...ue document.createcdatasection() true false true document.createprocessinginstruction() true false true document.createattribute() true true true document.createentityreference()obsolete since gecko 7 true false false document.ge
telementsbytagname() true true true document.importnode() true false true document.createelementns() true false true document.createattributens() true false true document.ge
telementsbytagnamens() true false true document.ge
telementbyid() true true true dom level 1 html support for properties/methods in document name firefox 1.5 ie 6 & 7 opera 8.54 - 9.01 ...
...And 6 more matches
Anatomy of a video game - Game development
this function does some work and also
tells the browser to call itself next frame with window.requestanimationframe().
... but do not immedia
tely assume animations require frame-by-frame control.
...for the first issue, if you want the main loop to just run and you do not need easy (direct) access to it, you could create it as an immedia
tely-invoked function expression (iife).
...And 6 more matches
CSS and JavaScript accessibility best practices - Learn web development
objective: to gain familiarity with using css and javascript appropria
tely in your web documents to maximise accessibility and not detract from it.
... as an example, a screen reader user can't navigate a page via heading elements if the developer hasn't appropria
tely used heading elements to markup the content.
...something should defini
tely happen when states change, and you shouldn't get rid of the pointer cursor or the outline — both are very important accessibility aids for those using keyboard controls.
...And 6 more matches
HTML: A good basis for accessibility - Learn web development
objective: to gain familiarity with the features of html that have accessibility benefits and how to use them appropria
tely in your web documents.
...some abuses of html are due to legacy practices that have not been comple
tely forgotten, and some are just plain ignorance.
...all rights reversed.</p> </td> </tr> </table> if you try to navigate this using a screen reader, it will probably
tell you that there's a table to be looked at (although some screen readers can guess the difference between table layouts and data tables).
...And 6 more matches
HTML: A good basis for accessibility - Learn web development
objective: to gain familiarity with the features of html that have accessibility benefits and how to use them appropria
tely in your web documents.
...some abuses of html are due to legacy practices that have not been comple
tely forgotten, and some are just plain ignorance.
...all rights reversed.</p> </td> </tr> </table> if you try to navigate this using a screen reader, it will probably
tell you that there's a table to be looked at (although some screen readers can guess the difference between table layouts and data tables).
...And 6 more matches
Accessibility in React - Learn web development
unfortuna
tely, these features are not very accessible to keyboard-only users.
... when we switch between templates in our <todo /> component, we comple
tely remove the elements that were there before to replace them with something else.
... targeting our elements in order to focus on an element in our dom, we need to
tell react which element we want to focus on and how to find it.
...And 6 more matches
Deployment and next steps - Learn web development
note that our application is fully functional and porting it to typescript is comple
tely optional.
...as we saw earlier, this instruction
tells svelte to compile our components and javascript files into a public/build/bundle.js file and all the css sections of our components into public/build/bundle.css.
... in the file package.json you can see that the dev and start scripts are just calling rollup: "scripts": { "build": "rollup -c", "dev": "rollup -c -w", "start": "sirv public" }, in the dev script we are passing the -w argument, which
tells rollup to watch files and rebuild on changes.
...And 6 more matches
Eclipse CDT
set an initial heap space of 1 gb and max heap space of 5 gb, say, by modifying the values of the following two lines in eclipse.ini: -xms1g -xmx5g if you fail to increase these limits, then you will likely find that eclipse either hangs when it tries to index the mozilla source or else that the code in
telligence is very broken after the indexing "completes".
...changes you make in one editor will be immedia
tely reflected in the other.
...alterna
tely, you can jump to the definition of the symbol under the cursor by pressing f3.
...And 6 more matches
Displaying Places information using views
getservice(ci.nsinavhistoryservice); var query = histserv.getnewquery(); query.searchterms = "mozilla"; query.onlybookmarked = true; var opts = histserv.getnewqueryoptions(); opts.querytype = opts.query_type_bookmarks; var uri = histserv.queriestoquerystring([query], 1, opts); var tree = document.ge
telementbyid("mytree"); tree.place = uri; these two examples use the built-in tree view, but the point is to demonstrate the use of the place attribute and property.
...for example, by setting a column's id to "title", you
tell the view to display the title of the nsinavhistoryresultnode of each row in that column.
... to put it in terms of javascript, say you have a variable named treeview that references your places tree view: var treeview = document.ge
telementbyid("myplacestreeview"); points 1 and 2 apply to this variable.
...And 6 more matches
Mozilla DOM Hacking Guide
for example, when we ask for |document.ge
telementbyid("myid");|, xpconnect will find that |document| is a property of the window object, so it will look on the interface nsidomwindow, and it will find the getdocument() method.
...so xpconnect will then try to find a method named ge
telementbyid() on the nsidomdocument interface.
...fortuna
tely, xpconnect provides us with a way to make our class available as an array in javascript.
...And 6 more matches
Investigating leaks using DMD heap scan mode
known edges: 0x7f08975a24c0 [fragmentorelement (xhtml) head https://www.example.com] --[mattrsandchildren[i]]--> 0x7f0882fe3230 0x7f08967e7b20 [js object (htmlscrip
telement)] --[unwrapdomobject(obj)]--> 0x7f0882fe3230 the first two lines mean that the script element 0x7f0882fe3230 contains a strong reference to the eventlistenermanager 0x7f0899b4e550.
...most of the time, the actual chain is not important, because the cycle collector can only
tell us about what went right.
...it
tells us that there is 1 unknown edge, and 2 known edges.
...And 6 more matches
NS_ConvertUTF16toUTF8
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
NS_LossyConvertUTF16toASCII
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsAdoptingCString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsCAutoString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...nt print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsCString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsDependentCString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsFixedCString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsPromiseFlatCString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsXPIDLCString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...ffset print32 acount print32 find(const char*, prbool, print32, print32) const - source parameters char* astring prbool aignorecase print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 6 more matches
nsIHTMLEditor
in astring atag, in nsidomnode aparentnode, in astring aanonclass, in boolean aiscreatedhidden); nsidomelement createelementwithdefaults(in astring atagname); void decreasefontsize(); void dodrag(in nsidomevent aevent); void getalignment(out boolean amixed, out short aalign); astring getbackgroundcolorstate(out boolean amixed); nsidomelement ge
telementorparentbytagname(in astring atagname, in nsidomnode anode); astring getfontcolorstate(out boolean amixed); astring getfontfacestate(out boolean amixed); astring getheadcontentsashtml(); astring gethighlightcolorstate(out boolean amixed); void getindentstate(out boolean acanindent, out boolean acanoutdent); void getinlineproperty(in nsiato...
... amixed, out boolean aol, out boolean aul, out boolean adl); astring getparagraphstate(out boolean amixed); nsidomelement getselectedelement(in astring atagname); nsidomelement getselectioncontainer(); void ignorespuriousdragevent(in boolean aignorespuriousdragevent); void increasefontsize(); void indent(in astring aindent); void inser
telementatselection(in nsidomelement aelement, in boolean adeleteselection); void insertfromdrop(in nsidomevent aevent); void inserthtml(in astring ainputstring); void inserthtmlwithcontext(in astring ainputstring, in astring acontextstr, in astring ainfostr, in astring aflavor, in nsidomdocument asourcedoc, in nsidomnode adestinationnode, in long adestinationoffset, in boo...
...perties(); void removedefaultproperty(in nsiatom aproperty, in astring aattribute, in astring avalue); void removeinlineproperty(in nsiatom aproperty, in astring aattribute); void removeinsertionlistener(in nsicontentfilter infilter); void removelist(in astring alisttype); void replaceheadcontentswithhtml(in astring asourcetoinsert); void selec
telement(in nsidomelement aelement); void setbackgroundcolor(in astring acolor); void setbodyattribute(in astring aattr, in astring avalue); void setcaretafterelement(in nsidomelement aelement); void setcssinlineproperty(in nsiatom aproperty, in astring aattribute, in astring avalue); void setdocumenttitle(in astring atitle); void setinlinepropert...
...And 6 more matches
Examples of web and XML development using the DOM - Web APIs
example 1: height and width the following example shows the use of the height and width properties alongside images of varying dimensions: <!doctype html> <html lang="en"> <head> <title>width/height example</title> <script> function init() { var arrimages = new array(3); arrimages[0] = document.ge
telementbyid("image1"); arrimages[1] = document.ge
telementbyid("image2"); arrimages[2] = document.ge
telementbyid("image3"); var objoutput = document.ge
telementbyid("output"); var strhtml = "<ul>"; for (var i = 0; i < arrimages.length; i++) { strhtml += "<li>image" + (i+1) + ": height=" + arrimages[i].height + ", width=" + arrimages[i].width + ", sty...
...ight, width, but style="height: 50px; width: 500px;" <img id="image3" src="https://udn.realityripple.com/samples/d2/8ba7141ed1.gif" style="height: 50px; width: 500px;"> </p> <div id="output"> </div> </body> </html> example 2: image attributes <!doctype html> <html lang="en"> <head> <title>modifying an image border</title> <script> function setborderwidth(width) { document.ge
telementbyid("img1").style.borderwidth = width + "px"; } </script> </head> <body> <p> <img id="img1" src="image1.gif" style="border: 5px solid green;" width="100" height="100" alt="border test"> </p> <form name="formname"> <input type="button" value="make border 20px-wide" onclick="setborderwidth(20);" /> <input type="button" value="make border 5px-wide" onclick="setbord...
... <!doctype html> <html lang="en"> <head> <title>changing color and font-size example</title> <script> function changetext() { var p = document.ge
telementbyid("pid"); p.style.color = "blue" p.style.fontsize = "18pt" } </script> </head> <body> <p id="pid" onclick="window.location.href = 'http://www.cnn.com/';">linker</p> <form> <p><input value="rec" type="button" onclick="changetext();" /></p> </form> </body> </html> example 4: using stylesheets the stylesheets property on the document object returns a list of the stylesheets that ...
...And 6 more matches
Element - Web APIs
nondocumenttypechildnode.nex
telementsibling read only is an element, the element immedia
tely following the given one in the tree, or null if there's no sibling node.
... nondocumenttypechildnode.previouselementsibling read only is a element, the element immedia
tely preceding the given one in the tree, or null if there is no sibling element.
... slotable.assignedslotread only returns a htmlslo
telement representing the <slot> the node is inserted in.
...And 6 more matches
Using files from web applications - Web APIs
accessing the first selected file using a classical dom selector: const selectedfile = document.ge
telementbyid('input').files[0]; accessing selected file(s) on a change event it is also possible (but not mandatory) to access the filelist through the change event.
... you need to use eventtarget.addeventlistener() to add the change event listener, like this: const inpu
telement = document.ge
telementbyid("input"); inpu
telement.addeventlistener("change", handlefiles, false); function handlefiles() { const filelist = this.files; /* now you can work with the file list */ } getting information about selected file(s) the filelist object provided by the dom lists all of the files selected by the user, each specified as a file object.
...let soutput = nbytes + " bytes"; // optional code for multiples approximation const amultiples = ["kib", "mib", "gib", "tib", "pib", "eib", "zib", "yib"]; for (nmultiple = 0, napprox = nbytes / 1024; napprox > 1; napprox /= 1024, nmultiple++) { soutput = napprox.tofixed(3) + " " + amultiples[nmultiple] + " (" + nbytes + " bytes)"; } // end of optional code document.ge
telementbyid("filenum").innerhtml = nfiles; document.ge
telementbyid("filesize").innerhtml = soutput; } document.ge
telementbyid("uploadinput").addeventlistener("change", updatesize, false); </script> </body> </html> using hidden file input elements using the click() method you can hide the admittedly ugly file <input> element and present your own interface for opening the file picker and...
...And 6 more matches
PerformanceNavigationTiming - Web APIs
the interface also supports the following properties: performancenavigationtiming.domcomplete read only a domhighrestimestamp representing a time value equal to the time immedia
tely before the browser sets the current document readiness of the current document to complete.
... performancenavigationtiming.domcontentloadedeventend read only a domhighrestimestamp representing the time value equal to the time immedia
tely after the current document's domcontentloaded event completes.
... performancenavigationtiming.domcontentloadedeventstart read only a domhighrestimestamp representing the time value equal to the time immedia
tely before the user agent fires the domcontentloaded event at the current document.
...And 6 more matches
Border-image generator - CSS: Cascading Style Sheets
pic = node.getattribute('data-topic'); var label = node.getattribute('data-label'); var selected = node.getattribute('data-selected') | 0; var select = document.createelement('div'); var list = document.createelement('div'); var uval = 0; var option = null; var option_value = null; list.classname = 'ui-dropdown-list'; select.classname = 'ui-dropdown-select'; while (node.firs
telementchild !== null) { option = node.firs
telementchild; option_value = option.getattribute('data-value'); if (option_value === null) option.setattribute('data-value', uval); list.appendchild(node.firs
telementchild); uval++; } node.appendchild(select); node.appendchild(list); select.onclick = this.toggle.bind(this); list.onclick = this.updatevalue.bind(this); docu...
...function init() { var elem = document.queryselectorall('.ui-checkbox'); var size = elem.length; for (var i = 0; i < size; i++) new checkbox(elem[i]); }; return { init : init, setvalue : setvalue, subscribe : subscribe, unsubscribe : unsubscribe }; })(); window.addeventlistener("load", function() { borderimage.init(); }); var borderimage = (function borderimage() { var ge
telembyid = document.ge
telementbyid.bind(document); var subject; var preview; var guidelines = []; var positions = ['top', 'right', 'bottom', 'left']; var makedraggable = function makedraggable(elem) { var offsettop; var offsetleft; elem.setattribute('data-draggable', 'true'); var dragstart = function dragstart(e) { if (e.target.getattribute('data-draggable') !== 'true' || e.
...gsource.width * scale / 100 | 0; var h = imgsource.height * scale / 100 | 0; subject.style.width = w + 'px'; subject.style.height = h + 'px'; for (var i = 0; i < positions.length; i++) guidelines['slice-' + positions[i]].updateguidelinepos(); }; var getscale = function getscale() { return scale/100; }; var togglegallery = function togglegallery() { var gallery = ge
telembyid('image-gallery'); var button = ge
telembyid('toggle-gallery'); var state = 1; button.addeventlistener('click', function() { state = 1 ^ state; if (state === 0) { gallery.setattribute('data-collapsed', 'true'); button.setattribute('data-action', 'show'); } else { gallery.removeattribute('data-collapsed'); button.setattribute('data-action', 'hide')...
...And 6 more matches
Relationship of grid layout to other layout methods - CSS: Cascading Style Sheets
grid and absolu
tely positioned elements grid interacts with absolu
tely positioned elements, which can be useful if you want to position an item inside a grid or grid area.
... the specification defines the behavior when a grid container is a containing block and a parent of the absolu
tely positioned item.
... a grid container as containing block to make the grid container a containing block you need to add the position property to the container with a value of relative, just as you would make a containing block for any other absolu
tely positioned items.
...And 6 more matches
Constraint validation - Developer guides
validation-related attributes in addition to the type attribute described above, the following attributes are used to describe basic constraints: attribute input types supporting the attribute possible values constraint description associated violation pattern text, search, url,
tel, email, password a javascript regular expression (compiled with the ecmascript 5 global, ignorecase, and multiline flags disabled) the value must match the pattern.
...tion date, month, week a valid date datetime, datetime-local, time a valid date and time max range, number a valid number the value must be less than or equal to the value rangeoverflow constraint violation date, month, week a valid date datetime, datetime-local, time a valid date and time required text, search, url,
tel, email, password, date, datetime, datetime-local, month, week, time, number, checkbox, radio, file; also on the <select> and <textarea> elements none as it is a boolean attribute: its presence means true, its absence means false there must be a value (if set).
... stepmismatch constraint violation month an integer number of months week an integer number of weeks datetime, datetime-local, time an integer number of seconds range, number an integer minlength text, search, url,
tel, email, password; also on the <textarea> element an integer length the number of characters (code points) must not be less than the value of the attribute, if non-empty.
...And 6 more matches
Applying color to HTML elements using CSS - HTML: Hypertext Markup Language
fortuna
tely, adding color to your html is actually really easy to do, and you can add color to nearly anything.
... let colorpicker = document.ge
telementbyid("colorpicker"); let box = document.ge
telementbyid("box"); let output = document.ge
telementbyid("output"); box.style.bordercolor = colorpicker.value; colorpicker.addeventlistener("input", function(event) { box.style.bordercolor = event.target.value; }, false); colorpicker.addeventlistener("change", function(event) { output.innertext = "color set to " + colorpicker.value + "."; }, f...
...fortuna
tely, there are tools available that can help you.
...And 6 more matches
Web video codec guide - Web media technologies
resolution (width and height) higher resolution video, presented in the same screen size, will typically be able to more accura
tely portray the original scene, barring effects introduced during compression.
...motion picture film is typically 24 frames per second, while standard definition
television is about 30 frames per second (slightly less, but close enough) and high definition
television is between 24 and 60 frames per second.
...it's a motion compensation based codec that is widely used today for all sorts of media, including broadcast
television, rtp videoconferencing, and as the video codec for blu-ray discs.
...And 6 more matches
Example - SVG: Scalable Vector Graphics
this is done comple
tely in w3c standards–xhtml, svg, and javascript–no flash or any vendor-specific extensions.
... </p> <p> this is done comple
tely in w3c standards–xhtml, svg and javascript–no flash or any vendor specific extensions. currently, this will work in mozilla firefox version 1.5 and above.
... </p> <div> (c) 2006 <a id='emailme' href='#'>nick johnson</a> <script type='text/javascript'> <![cdata[ // foil spam bots var email = '@riovia.net'; email ='nick' + email; document.ge
telementbyid('emailme').href = 'mailto:'+email; ]]> </script> this software is free for you to use in any way whatsoever, and comes with no warranty at all.
...And 6 more matches
Appendix C: Avoiding using eval in Add-ons - Archive of obsolete content
in order to host your add-on with mozilla it is crucial to minimize or comple
tely eliminate eval use in order to receive a positive review and have your add-on made public.
... jsonp, which really is just another script tag containing generated, remo
tely retrieved code, is generally not secure.
... other extensions might do something similar, trying to hook the same functions, but a little different, ending up with comple
tely broken code.
...And 5 more matches
Index - Archive of obsolete content
459 checkadjacen
telement xul methods, xul reference no summary!
... 483 ge
telementsbyattribute xul methods, xul reference no summary!
... 484 ge
telementsbyattributens xul methods, xul reference no summary!
...And 5 more matches
Document Object Model - Archive of obsolete content
retrieving elements the most common method to retrieve an element in a document is to give the element an id attribute and the use the document's ge
telementbyid() method.
...for example, we could get the state of a check box by using the code below: var state = document.ge
telementbyid('casecheck').checked; the value casecheck corresponds to the id of the case sensitive checkbox.
... function dofind(){ var meter = document.ge
telementbyid('progmeter'); meter.hidden = false; } this function first gets a reference to the progress meter using its id, progmeter.
...And 5 more matches
splitter - Archive of obsolete content
before when the grippy is clicked, the element immedia
tely before the splitter in the same parent is collapsed so that its width or height is 0.
... after when the grippy is clicked, the element immedia
tely after the splitter in the same parent is collapsed so that its width or height is 0.
... both either the element immedia
tely before the splitter, or the element immedia
tely after the splitter can be collapsed, if the size of that element would fall below the minimum size due to the position of the splitter.
...And 5 more matches
RDF in Mozilla FAQ - Archive of obsolete content
unfortuna
tely, not here!
...var ds = rdf.getdatasource("http://www.mozilla.org/some-rdf-file.rdf"); // note that ds will load asynchronously, so assertions will not // be immedia
tely available alternatively, you can create one directly using the xpcom component manager, as the following code fragment illustrates: // create an rdf/xml datasource using the xpcom component manager var ds = components .classes["@mozilla.org/rdf/datasource;1?name=xml-datasource"] .createinstance(components.interfaces.nsirdfdatasource); // the nsirdfremotedatasource interface has the inte...
...by setting // ablocking to true, we could force it to be synchronous, but this // is generally a bad idea, because your ui will comple
tely lock up!
...And 5 more matches
Client-side form validation - Learn web development
if it gets to the server and is then rejected, a noticeable delay is caused by a round trip to the server and then back to the client-side to
tell the user to fix their data.
...this validation is comple
tely customizable, but you need to create it all (or use a library).
... the constraint validation api most browsers support the constraint validation api, which consists of a set of methods and properties available on the following form element dom interfaces: htmlbuttonelement (represents a <button> element) htmlfieldse
telement (represents a <fieldset> element) htmlinpu
telement (represents an <input> element) htmloutpu
telement (represents an <output> element) htmlselec
telement (represents a <select> element) htmltextareaelement (represents a <textarea> element) the constraint validation api makes the following properties available on the above elements.
...And 5 more matches
HTML text fundamentals - Learn web development
ied to a fish.</textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var solution = document.ge
telementbyid('solution'); var output = document.queryselector('.output'); var code = textarea.value; var userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutione...
... semantics are relied on everywhere around us—we rely on previous experience to
tell us what the function of an everyday object is; when we see something, we know what its function will be.
...s bread hummus</textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var solution = document.ge
telementbyid('solution'); var output = document.queryselector('.output'); var code = textarea.value; var userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutione...
...And 5 more matches
Creating reftest-based unit tests
this is why manual tests tend to get longer, include more steps and ultima
tely become a long list that actually tests a lot of things.
...it is comple
tely trivial, but so what.
... more investigation into whether this will work is defini
tely warranted.
...And 5 more matches
HTML parser threading
the backing nsstringbuffers are thread-safely refcounted appropria
tely when the nsstring goes away.
...this method returns immedia
tely if another invocation of it is already on the call stack (nested event loop case).
...parser termination is checked before each tree op for an early return, because, unfortuna
tely, gecko expects parsers to be able to terminate immedia
tely.
...And 5 more matches
An overview of NSS Internals
many (if not most) of the operations performed by nss involve the use of x.509 certificates (often abbreviated as “cert”, unfortuna
tely making it easy to confuse with the term “computer emergency response team“).
...a trust anchor is just another x.509 certificate that is already known and has been delibera
tely marked as trusted by a software vendor, administrators inside an organizational infrastructure, or the software user.
... because of nss's expectation to operate with an nss database, it's mandatory that you perform an initialization call, where you
tell nss which database you will be using.
...And 5 more matches
nss tech note1
the type is undefined as it is comple
tely dependent on the content of the decoder templates.† this typically points to a struct that is described (or partially described) by the templates.
... decoder templates : the sec_asn1template structure
tells the decoder what to do with the input data.
...this 32-bit field
tells the decoder what to do with a particular component within the input data.
...And 5 more matches
nsIDocShell
method overview void addsessionstorage(in nsiprincipal principal, in nsidomstorage storage); void addstate(in nsivariant adata, in domstring atitle, in domstring aurl, in boolean areplace); void beginrestore(in nsicontentviewer viewer, in boolean top); void createaboutblankcontentviewer(in nsiprincipal aprincipal); void crea
teloadinfo(out nsidocshellloadinfo loadinfo); void detacheditorfromwindow(); violates the xpcom interface guidelines void finishrestore(); void firepagehidenotification(in boolean isunload); native code only!
... canvashasfocus boolean
tells the docshell whether the canvas should have focus.
... hasfocus boolean
tells the docshell that it now has focus or has lost focus.
...And 5 more matches
nsIRadioInterfaceLayer
dom/system/gonk/nsiradiointerfacelayer.idlscriptable used to implement the interface between the
telephony api and the radio hardware in a
telephone.
... 1.0 66 introduced gecko 12.0 inherits from: nsisupports last changed in gecko 14.0 (firefox 14.0 / thunderbird 14.0 / seamonkey 2.11) implemented by: @mozilla.org/
telephony/system-worker-manager;1.
... to create an instance, use: var radiointerfacelayer = components.classes["@mozilla.org/
telephony/system-worker-manager;1"] .getservice(components.interfaces.nsiinterfacerequestor) .createinstance(components.interfaces.nsiradiointerfacelayer); method overview void answercall(in unsigned long callindex); void deactivatedatacall(in domstring cid, in domstring reason); void dial(in domstring number); void enumeratecalls(in nsiril
telephonycallback callback); void getdatacalllist(); unsigned short getnumberofmessagesfortext(in domstring text); void hangup(in unsigned long callindex); void registercallback(in nsiril
telephonycallback callback); void registerdatacallcallback(in nsirildatacallback callback); void rejectcall(in u...
...And 5 more matches
Getting Started Guide
each interface is (at least conceptually) separa
tely `reference counted'.
...the caller can then hold onto the reference indefini
tely, calling release when it no longer needs it.
...as described above, and unless you
tell it otherwise, an nscomptr addrefs when you assign in to it.
...And 5 more matches
Background Tasks API - Web APIs
window.requestidlecallback() makes it possible to become actively engaged in helping to ensure that the browser's event loop runs smoothly, by allowing the browser to
tell your code how much time it can safely use without causing the system to lag.
... let totaltaskcoun
telem = document.ge
telementbyid("totaltaskcount"); let currenttasknumberelem = document.ge
telementbyid("currenttasknumber"); let progressbarelem = document.ge
telementbyid("progress"); let startbuttonelem = document.ge
telementbyid("startbutton"); let logelem = document.ge
telementbyid("log"); next we have variables which reference the dom elements we need to interact with.
... these elements are: totaltaskcoun
telem is the <span> we use to insert the total number of tasks created into the status display in the progress box.
...And 5 more matches
CanvasRenderingContext2D.filter - Web APIs
a value of 0% will create an image that is comple
tely black, while a value of 100% leaves the input unchanged.
...a value of 0% will create a drawing that is comple
tely black.
...a value of 100% is comple
tely grayscale.
...And 5 more matches
Basic animations - Web APIs
requestanimationframe(callback)
tells the browser that you wish to perform an animation and requests that the browser call a specified function to update an animation before the next repaint.
... var sun = new image(); var moon = new image(); var earth = new image(); function init() { sun.src = 'https://mdn.mozillademos.org/files/1456/canvas_sun.png'; moon.src = 'https://mdn.mozillademos.org/files/1443/canvas_moon.png'; earth.src = 'https://mdn.mozillademos.org/files/1429/canvas_earth.png'; window.requestanimationframe(draw); } function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); ctx.globalcompositeoperation = 'destination-over'; ctx.clearrect(0, 0, 300, 300); // clear canvas ctx.fillstyle = 'rgba(0, 0, 0, 0.4)'; ctx.strokestyle = 'rgba(0, 153, 255, 0.4)'; ctx.save(); ctx.translate(150, 150); // earth var time = new date(); ctx.rotate(((2 * math.pi) / 60) * time.getseconds() + ((2 * math.pi) / 60000) * time.getmill...
... function clock() { var now = new date(); var ctx = document.ge
telementbyid('canvas').getcontext('2d'); ctx.save(); ctx.clearrect(0, 0, 150, 150); ctx.translate(75, 75); ctx.scale(0.4, 0.4); ctx.rotate(-math.pi / 2); ctx.strokestyle = 'black'; ctx.fillstyle = 'white'; ctx.linewidth = 8; ctx.linecap = 'round'; // hour marks ctx.save(); for (var i = 0; i < 12; i++) { ctx.beginpath(); ctx.rotate(math.pi / 6); ctx.moveto(100, 0);...
...And 5 more matches
EventTarget.addEventListener() - Web APIs
because older browsers (as well as some not-too-old browsers) still assume the third parameter is a boolean, you need to build your code to handle this scenario in
telligently.
... html <table id="outside"> <tr><td id="t1">one</td></tr> <tr><td id="t2">two</td></tr> </table> javascript // function to change the content of t2 function modifytext() { const t2 = document.ge
telementbyid("t2"); if (t2.firstchild.nodevalue == "three") { t2.firstchild.nodevalue = "two"; } else { t2.firstchild.nodevalue = "three"; } } // add event listener to table const el = document.ge
telementbyid("outside"); el.addeventlistener("click", modifytext, false); in this code, modifytext() is a listener for click events registered using addeventlistener().
... html <table id="outside"> <tr><td id="t1">one</td></tr> <tr><td id="t2">two</td></tr> </table> javascript // function to change the content of t2 function modifytext(new_text) { const t2 = document.ge
telementbyid("t2"); t2.firstchild.nodevalue = new_text; } // function to add event listener to table const el = document.ge
telementbyid("outside"); el.addeventlistener("click", function(){modifytext("four")}, false); notice that the listener is an anonymous function that encapsulates code that is then, in turn, able to send parameters to the modifytext() function, which is responsible for actual...
...And 5 more matches
Capabilities, constraints, and settings - Web APIs
historically, writing scripts for the web that work intima
tely with web apis has had a well-known challenge: often, your code needs to know whether or not an api exists and if so, what its limitations are on the user agent it's running on.
... overview the process works like this (using mediastreamtrack as an example): if needed, call mediadevices.getsupportedconstraints() to get the list of supported constraints, which
tells you what constrainable properties the browser knows about.
... determining if a constraint is supported if you need to know whether or not a given constriant is supported by the user agent, you can find out by calling navigator.mediadevices.getsupportedconstraints() to get a list of the constrainable properties which the browser knows, like this: let supported = navigator.mediadevices.getsupportedconstraints(); document.ge
telementbyid("framerateslider").disabled = !supported["framerate"]; in this example, the supported constraints are fetched, and a control that lets the user configure the frame rate is disabled if the framerate constraint isn't supported.
...And 5 more matches
filter - CSS: Cascading Style Sheets
when a single filter property has two or more functions it's results will be different from when two or more filter properties are separa
tely applied with the same functions.
...a value of 0% will create an image that is comple
tely black.
...a value of 0% will create an image that is comple
tely gray.
...And 5 more matches
Closures - JavaScript
document.ge
telementbyid('size-12').onclick = size12; document.ge
telementbyid('size-14').onclick = size14; document.ge
telementbyid('size-16').onclick = size16; <a href="#" id="size-12">12</a> <a href="#" id="size-14">14</a> <a href="#" id="size-16">16</a> run the code using jsfiddle.
... notice that i defined an anonymous function that creates a counter, and then i call it immedia
tely and assign the result to the counter variable.
... <p id="help">helpful notes will appear here</p> <p>e-mail: <input type="text" id="email" name="email"></p> <p>name: <input type="text" id="name" name="name"></p> <p>age: <input type="text" id="age" name="age"></p> function showhelp(help) { document.ge
telementbyid('help').innerhtml = help; } function setuphelp() { var helptext = [ {'id': 'email', 'help': 'your e-mail address'}, {'id': 'name', 'help': 'your full name'}, {'id': 'age', 'help': 'your age (you must be over 16)'} ]; for (var i = 0; i < helptext.length; i++) { var item = helptext[i]; document.ge
telementbyid(item.id).onfocus = function() { showhel...
...And 5 more matches
Math - JavaScript
static properties math.e euler's constant and the base of natural logarithms; approxima
tely 2.718.
... math.ln2 natural logarithm of 2; approxima
tely 0.693.
... math.ln10 natural logarithm of 10; approxima
tely 2.303.
...And 5 more matches
The building blocks of responsive design - Progressive web apps (PWAs)
one approach to this is to create different versions of your site/app for different platforms or browsers and serve them appropria
tely after detecting which browser or platform is looking at your site.
... it is usually much better to create a single version of your code which doesn't care about what browser or platform is accessing the site, but instead uses feature tests to find out what code features the browser supports or what the values of certain browser features are, and then adjusts the code appropria
tely.
...this is pretty horrible, but generally this kind of problem is easily fixed with some simple css: img, video { max-width: 100%; } this
tells the replaced elements to remain constrained inside their container's widths, no matter what.
...And 5 more matches
Interacting with page scripts - Archive of obsolete content
expose objects to page scripts until firefox 30, you could use unsafewindow to perform the reverse procedure, and make objects defined in content scripts available to page scripts: // content-script.js unsafewindow.contentscriptobject = {"greeting" : "hello from add-on"}; // page-script.js var button = document.ge
telementbyid("show-content-script-var"); button.addeventlistener("click", function() { // access object defined by content script console.log(window.contentscriptobject.greeting); // "hello from add-on" }, false); after firefox 30, you can still do this for primitive values, but can no longer do it for objects.
... the "page.html" file adds two buttons and assigns an event listener to each: one listener displays a property of the cloned object, and the other listener displays a property of the assigned object: <html> <head> </head> <body> <input id="works" type="button" value="i will work"/> <input id="fails" type="button" value="i will not work"/> <script> var works = document.ge
telementbyid("works"); works.addeventlistener("click", function() { alert(clonedcontentscriptobject.greeting); }, false); var fails = document.ge
telementbyid("fails"); fails.addeventlistener("click", function() { alert(assignedcontentscriptobject.greeting); }, false); </script> </body> </html> if you run the example, clicking "i will work" displa...
...utation = "hello, "; function greetme(user) { return salutation + user; } exportfunction(greetme, unsafewindow, {defineas: "greetme"}); finally, the "page.html" file adds a button and a page script that calls the exported function when the user pushes the button: <html> <head> </head> <body> <input id="test" type="button" value="click me"/> <script> var test = document.ge
telementbyid("test"); test.addeventlistener("click", function() { alert(window.greetme("page script")); }, false); </script> </body> </html> exportfunction() works by structured cloning the arguments and return value of the function from one scope to the other.
...And 4 more matches
jpm - Archive of obsolete content
you should revoke and regenerate compromised api credentials immedia
tely.
... if you do not list your add-on on addons.mozilla.org, you need to generate a mozilla-signed xpi and
tell firefox where it can find new versions of your add-on.
... the way this works is: you run jpm sign anytime you need to create a new version you host the signed add-on xpi and update it when you need to you host an "update manifest", which, among other things, contains a url pointing to the xpi your add-on
tells firefox where it can find the update manifest to do this, include two extra keys in package.json: updateurl: this url is included in the install manifest of the xpi file that jpm xpi builds.
...And 4 more matches
StringView - Archive of obsolete content
vinput.by
telength >>> 2 : this.encoding === "utf-16" ?
... vinput.by
telength >>> 1 : vinput.by
telength; araw = nstartidx === 0 && (!isfinite(nlength) || nlength === ninptlen) ?
... vinput.buffer.by
telength >>> 2 : ftaview === uint16array ?
...And 4 more matches
The Essentials of an Extension - Archive of obsolete content
if we open the chrome.manifest file (again, any text editor will do), we see that the same 3 sections are mentioned: content xulschoolhello content/ skin xulschoolhello classic/1.0 skin/ locale xulschoolhello en-us locale/ the chrome.manifest file
tells firefox where to look for chrome files.
... the first word in a line
tells firefox what it is that is being declared (content, skin, locale, or others mentioned later on).
...we're adding a menu of our own, and
telling firefox to add it in that pane, right after the add-ons item.
...And 4 more matches
MMgc - Archive of obsolete content
alterna
tely, you can open the mmgc namespace in your c++ source so that you can refer to the objects more concisely: using namespace mmgc; ...
...zeroing rcobjects all rcobjects (including all subclasses) must zero themselves out comple
tely upon destruction.
...(the second switch will slow your application down a lot more than the first switch, so you could try the first, then the second.) when a missing write barrier is detected, mmgc will assert and drop you into the debugger, and will print out a message
telling you which object contained the missing write barrier, the address of the member variable that needs it, and what object didn't get marked due to the missing write barrier.
...And 4 more matches
Using the Editor from XUL - Archive of obsolete content
something, somewhere,
tells mozilla to open the composer window.
...having an id attribute, id="content-frame", allows us to find this element with document.ge
telementbyid("content-frame"), and to style it from css.
...we could either pass document.ge
telementbyid("content-frame") or window._content here.
...And 4 more matches
Introduction to SSL - Archive of obsolete content
because the key size is so large, there are more possible keys than for any other cipher-approxima
tely 3.7 * 1050.
...rc4 and rc2 128-bit encryption permits approxima
tely 3.4 * 1038 possible keys, making them very difficult to crack.
...rc4 and rc2 128-bit encryption permits approxima
tely 3.4 * 1038 possible keys, making them very difficult to crack.
...And 4 more matches
Grids - Learn web development
add this to the css inside your file: .container { display: grid; } unlike flexbox, the items will not immedia
tely look any different.
...cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...curabitur vehicula
tellus neque, ac ornare ex malesuada et.
...And 4 more matches
How does the Internet work? - Learn web development
by connecting computers to routers, then routers to routers, we are able to scale infini
tely.
...well, there are already cables linked to your house, for example, electric power and
telephone.
... the
telephone infrastructure already connects your house with anyone in the world so it is the perfect wire we need.
...And 4 more matches
How to build custom form controls - Learn web development
if you consider that the active state and the open state are comple
tely different, the answer is again "nothing will happen" because we did not define any keyboard interactions for the opened state.
... on the other hand, if you consider that the active state and the open state overlap a bit, the value may change but the option will defini
tely not be highlighted accordingly, once again because we did not define any keyboard interactions over options when the control is in its opened state (we have only defined what should happen when the control is opened, but nothing after that).
...they had the market share to successfully introduce a comple
tely new way of interacting with a device, something most device companies can't do.
...And 4 more matches
Index - Learn web development
beginner, express, flask, learn, node, php, python, django, lamp, server-side, servers throughout most of the learning area, we
tell you to just open your examples directly in a browser — this can be done by double clicking the html file, dragging and dropping it into the browser window, or choosing file > open...
... 41 installing basic software beginner, browser, learn, setup, tools, webmechanics, l10n:priority, text editor that looks like a scary list, but fortuna
tely, you can get started in web development without knowing anything about most of these.
... 76 a first splash into javascript article, beginner, codingscripting, conditionals, functions, javascript, learn, objects, operators, variables, events, l10n:priority now you've learned something about the theory of javascript, and what you can do with it, we are going to give you a crash course in the basic features of javascript via a comple
tely practical tutorial.
...And 4 more matches
Graceful asynchronous programming with Promises - Learn web development
also, the user may not respond immedia
tely to these permission requests.
... the important thing here is that the getusermedia() call returns almost immedia
tely, even if the camera stream hasn't been obtained yet.
... we immedia
tely run the blob() method on this response to ensure that the response body is fully downloaded, and when it is available transform it into a blob object that we can do something with.
...And 4 more matches
Cooperative asynchronous JavaScript: Timeouts and intervals - Learn web development
introduction for a long time, the web platform has offered javascript programmers a number of functions that allow them to asynchronously execute code after a certain time interval has elapsed, and to repeatedly execute a block of code asynchronously until you
tell it to stop.
...(see the note below on why it runs "as soon as possible" and not "immedia
tely".) more on why you might want to do this later.
... as a consequence, code like settimeout(fn, 0) will execute as soon as the stack is empty, not immedia
tely.
...And 4 more matches
Build your own function - Learn web development
this is fine, as you can
tell them apart — function names appear with parentheses after them, and variables don't.
... try including the following line below your function to call it: displaymessage(); this line invokes the function, making it run immedia
tely.
... when you save your code and reload it in the browser, you'll see the little message box appear immedia
tely, only once.
...And 4 more matches
Looping code - Learn web development
body { margin: 0; } button { position: absolute; top: 5px; left: 5px; } </style> </head> <body> <button>update</button> <canvas></canvas> <script> const btn = document.queryselector('button'); const canvas = document.queryselector('canvas'); const ctx = canvas.getcontext('2d'); let width = document.documen
telement.clientwidth; let height = document.documen
telement.clientheight; canvas.width = width; canvas.height = height; function random(number) { return math.floor(math.random()*number); } function draw() { ctx.clearrect(0,0,width,height); for (let i = 0; i < 100; i++) { ctx.beginpath(); ctx.fillstyle = 'rgba(255,0,0,0.5)'; ctx.arc(...
...if we set it to i === cats.length, the loop would not run at all because i is not equal to 5 on the first loop iteration, so it would stop immedia
tely.
...we already met this in the previous article when we looked at switch statements — when a case is met in a switch statement that matches the input expression, the break statement immedia
tely exits the switch statement and moves onto the code after it.
...And 4 more matches
Drawing graphics - Learn web development
note that on each frame we are comple
tely clearing the canvas and redrawing everything.
...we are delibera
tely slowing down the frame rate because we only have six sprites to work with, and if we display one every 60th of a second, our character will move way too fast!
...e.pagex : e.clientx + (document.documen
telement.scrollleft ?
...And 4 more matches
What is JavaScript? - Learn web development
browser security each browser tab has its own separate bucket for running code in (these buckets are called "execution environments" in technical terms) — this means that in most cases the code in each tab is run comple
tely separa
tely, and the code in one tab cannot directly affect the code in another tab — or on another website.
...in interpreted languages, the code is run from top to bottom and the result of running the code is immedia
tely returned.
...if you are using javascript to manipulate elements on the page (or more accura
tely, the document object model), your code won't work if the javascript is loaded and parsed before the html you are trying to do something to.
...And 4 more matches
Getting started with React - Learn web development
note the use of ./ at the beginning of the path, and the .svg extension at the end — these
tell us that the file is local and that it is not a javascript file.
...this expression defines what your browser ultima
tely renders to the dom.
...you'll notice that this change is immedia
tely rendered in the development server running at http://localhost:3000 in your browser.
...And 4 more matches
Handling common accessibility problems - Learn web development
when we say accessibility in the context of web technology, most people immedia
tely think of making sure websites/apps are usable by people with disabilities, for example: visually impaired people using screen readers or magnification/zoom to access text people with motor function impairments using the keyboard (or other non-mouse features) to activate website functionality.
...defines accessibility more comple
tely and thoroughly than this article does.
...ou can try this out using our native-keyboard-accessibility.html example (see the source code) — open this in a new tab, and try pressing the tab key; after a few presses, you should see the tab focus start to move through the different focusable elements; the focused elements are given a highlighted default style in every browser (it differs slightly between different browsers) so that you can
tell what element is focused.
...And 4 more matches
OS.File for the main thread
if (pos <= view.by
telength) { // note: should this be pos >= view.by
telength ?
... file.close(); }, function onerror(reason) { file.close(); throw reason; }); return promise; } or a variant using task.js (or at least the subset already present on mozilla-central): let writestream = function writestream(data, outfile, chunksize) { return task.spawn(function() { let view = new uint8array(data); let pos = 0; while (pos < view.by
telength) { pos += yield outfile.write(view.subarray(pos, chunksize)); } outfile.close(); }).then( null, function onfailure(reason) { outfile.close(); throw reason; } ); } example: save canvas to disk this exmaple uses image to load an image from a path (note: if your path is a file on disk you must use local file; this is accomplished with os.path.tofileu...
...note: if from is specified then even if ignoreexisting is specified as false, it will not fail due to pre-existence of directories, because the from option
tells makedir to make the folders if not found.
...And 4 more matches
NSS API Guidelines
these rules are here to help us all immedia
tely achieve more consistent and usable code, but some existing code won't follow all these rules.
...in addition, some low-level apis may be comple
tely opaque to higher level layers.
...fortuna
tely most of the existing api has the correct semantics.
...And 4 more matches
NS_ConvertASCIItoUTF16
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
NS_ConvertUTF8toUTF16
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsAdoptingString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsAutoString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsDependentString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsFixedString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsPromiseFlatString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsXPIDLString
@param astring is substring to be sought in this @param aignorecase selects case sensitivity @param aoffset
tells us where in this string to start searching @param acount
tells us how far from the offset we are to search.
...string print32 aoffset print32 acount print32 find(const prunichar*, print32, print32) const - source parameters prunichar* astring print32 aoffset print32 acount rfind print32 rfind(const nscstring&, prbool, print32, print32) const - source this methods scans the string backwards, looking for the given string @param astring is substring to be sought in this @param aignorecase
tells us whether or not to do caseless compare @param aoffset
tells us where in this string to start searching.
...@param acount
tells us how many iterations to make starting at the given offset.
...And 4 more matches
nsILivemarkService
to use this service, use: var livemarkservice = components.classes["@mozilla.org/browser/livemark-service;2"] .getservice(components.interfaces.nsilivemarkservice); method overview long long crea
telivemark(in long long folder, in astring name, in nsiuri siteuri, in nsiuri feeduri, in long index); long long crea
telivemarkfolderonly(in long long folder, in astring name, in nsiuri siteuri, in nsiuri feeduri, in long index); nsiuri getfeeduri(in long long container); long long getlivemarkidforfeeduri(in nsiuri afeeduri); nsiuri getsiteuri(in long long contai...
...ner); boolean islivemark(in long long folder); void reloadalllivemarks(); void reloadlivemarkfolder(in long long folderid); void setfeeduri(in long long container, in nsiuri feeduri); void setsiteuri(in long long container, in nsiuri siteuri); void start(); void stopupda
telivemarks(); methods crea
telivemark() creates a new livemark.
... long long crea
telivemark( in long long folder, in astring name, in nsiuri siteuri, in nsiuri feeduri, in long index ); parameters folder the id of the parent folder.
...And 4 more matches
Using the clipboard
tell the transferring object about the type of data being copied.
...
tell the transferring object about the data to copy.
...
tell the clipboard object to copy the data using the transferring object.
...And 4 more matches
WebIDL bindings
this should only be used when it's absolu
tely guaranteed that the return value of the attribute getter will always be the same from the js engine's point of view.
...such attributes will have their getter called immedia
tely when the js wrapper for the dom object is created, and the returned value will be stored directly on the js object.
...this will immedia
tely call the c++ getter and cache the value it returns, so it needs a jscontext to work on.
...And 4 more matches
URLs - Plugins
telnet (reference to interactive sessions) locates an interactive service.
... note that npn_geturl is typically asynchronous: it returns immedia
tely and only later handles the request, such as displaying the url or creating the stream for the instance and writing the data.
...it returns immedia
tely and only later handles the request and calls npp_urlnotify.
...And 4 more matches
WebGL constants - Web APIs
standard webgl constants are installed on the webglrenderingcontext and webgl2renderingcontext objects, so that you use them as gl.constant_name: var canvas = document.ge
telementbyid('mycanvas'); var gl = canvas.getcontext('webgl'); gl.getparameter(gl.line_width); some constants are also provided by webgl extensions.
... blending modes constants passed to webglrenderingcontext.blendfunc() or webglrenderingcontext.blendfuncseparate() to specify the blending mode (for both, rbg and alpha, or separa
tely).
... blending equations constants passed to webglrenderingcontext.blendequation() or webglrenderingcontext.blendequationseparate() to control how the blending is calculated (for both, rbg and alpha, or separa
tely).
...And 4 more matches
Writing WebSocket servers - Web APIs
section 10 discusses security and you should defini
tely peruse it before exposing your server.
... if any header is not understood or has an incorrect value, the server should send a 400 ("bad request")} response and immedia
tely close the socket.
... | +---------------------------------------------------------------+ the mask bit
tells whether the message is encoded.
...And 4 more matches
Viewpoints and viewers: Simulating cameras in WebXR - Web APIs
fortuna
tely, physicists like galileo, newton, lorentz, and einstein have given us the principle of relativity, which states that the laws of physics have the same form in every frame of reference.
...a third party can
tell the difference, but the two of you cannot.
...gaming-related situations are listed separa
tely since they are often a special case specific to gaming, but any of these perspectives might apply to any 3d graphics scene.
...And 4 more matches
Using the Web Animations API - Web APIs
animation: alicetumbling infinite 3s linear; } @keyframes alicetumbling { 0% { color: #000; transform: rotate(0) translate3d(-50%, -50%, 0); } 30% { color: #431236; } 100% { color: #000; transform: rotate(360deg) translate3d(-50%, -50%, 0); } } this changes alice’s color and her transform’s rotation over 3 seconds at a constant (linear) rate and loops infini
tely.
... bring the pieces together now it’s time to bring them both together with the element.animate() method: document.ge
telementbyid("alice").animate( alicetumbling, alicetiming ) and boom: the animation starts playing (see the finished version on codepen).
...instead of making objects for keyframes and timing properties, we could just pass their values in directly, like so: document.ge
telementbyid("alice").animate( [ { transform: 'rotate(0) translate3d(-50%, -50%, 0)', color: '#000' }, { color: '#431236', offset: 0.3}, { transform: 'rotate(360deg) translate3d(-50%, -50%, 0)', color: '#000' } ], { duration: 3000, iterations: infinity } ); what’s more, if we only wanted to specify the duration of the animation and not its iterations (by default, animations iterate once), we could pass in the milliseconds alone: document.ge
telementbyid("alice").animate( [ { transform: 'rotate(0) translate...
...And 4 more matches
Web APIs
se batterymanager beforeinstallpromptevent beforeunloadevent biquadfilternode blob blobbuilder blobevent bluetooth bluetoothadvertisingdata bluetoothcharacteristicproperties bluetoothdevice bluetoothremotegattcharacteristic bluetoothremotegattdescriptor bluetoothremotegattserver bluetoothremotegattservice body broadcastchannel budgetservice budgetstate buffersource by
telengthqueuingstrategy bytestring c cdatasection css cssconditionrule csscounterstylerule cssgroupingrule cssimagevalue csskeyframerule csskeyframesrule csskeywordvalue cssmathproduct cssmathsum cssmathvalue cssmediarule cssnamespacerule cssnumericvalue cssomstring csspagerule csspositionvalue cssprimitivevalue csspseudoelement cssrule cssrulelist cssstyledeclaration cssstyl...
...ceset fontfacesetloadevent formdata formdataentryvalue formdataevent fullscreenoptions g gainnode gamepad gamepadbutton gamepadevent gamepadhapticactuator geolocation geolocationcoordinates geolocationposition geolocationpositionerror geometryutils gestureevent globaleventhandlers gyroscope h htmlanchorelement htmlareaelement htmlaudioelement htmlbrelement htmlbaseelement htmlbasefon
telement htmlbodyelement htmlbuttonelement htmlcanvaselement htmlcollection htmlconten
telement htmldlis
telement htmldataelement htmldatalis
telement htmldetailselement htmldialogelement htmldivelement htmldocument htmlelement htmlembedelement htmlfieldse
telement htmlfon
telement htmlformcontrolscollection htmlformelement htmlframese
telement htmlhrelement htmlheadelement htmlheadingelement htm...
...lhtmlelement htmlhyperlinkelementutils htmliframeelement htmlimageelement htmlinpu
telement htmlisindexelement htmlkeygenelement htmllielement htmllabelelement htmllegendelement htmllinkelement htmlmapelement htmlmarqueeelement htmlmediaelement htmlmenuelement htmlmenuitemelement htmlmetaelement htmlmeterelement htmlmodelement htmlolis
telement htmlobjec
telement htmloptgroupelement htmloptionelement htmloptionscollection htmlorforeignelement htmloutpu
telement htmlparagraphelement htmlparamelement htmlpictureelement htmlpreelement htmlprogresselement htmlquoteelement htmlscrip
telement htmlselec
telement htmlshadowelement htmlslo
telement htmlsourceelement htmlspanelement htmlstyleelement htmltablecaptionelement htmltablecellelement htmltablecolelement htmltableelement htmltablerowele...
...And 4 more matches
Linear-gradient Generator - CSS: Cascading Style Sheets
property { width: 90%; margin: 5px 5%; color: #777; position: relative; float: left; } #output .property { height: 100%; width: 12%; position: absolute; left: 0; } #output .value { width: 88%; position: absolute; white-space: pre; word-wrap: break-word; display: block; right: 0; } javascript content var uicolorpicker = (function uicolorpicker() { 'use strict'; function ge
telembyid(id) { return document.ge
telementbyid(id); } var subscribers = []; var pickers = []; /** * rgba color class * * hsv/hsb and hsl (hue, saturation, value / brightness, lightness) * @param hue 0-360 * @param saturation 0-100 * @param value 0-100 * @param lightness 0-100 */ function color(color) { if(color instanceof color === true) { this.copy(color); ret...
...pic = node.getattribute('data-topic'); var label = node.getattribute('data-label'); var selected = node.getattribute('data-selected') | 0; var select = document.createelement('div'); var list = document.createelement('div'); var uval = 0; var option = null; var option_value = null; list.classname = 'ui-dropdown-list'; select.classname = 'ui-dropdown-select'; while (node.firs
telementchild !== null) { option = node.firs
telementchild; option_value = option.getattribute('data-value'); if (option_value === null) option.setattribute('data-value', uval); list.appendchild(node.firs
telementchild); uval++; } node.appendchild(select); node.appendchild(list); select.onclick = this.toggle.bind(this); list.onclick = this.updatevalue.bind(this); docu...
...subscribe }; })(); window.addeventlistener("load", function() { lineargradienttool.init(); }); window.addeventlistener("load", function() { lineargradienttool.init(); }); var lineargradienttool = (function lineargradienttool() { 'use strict'; var radian = 180 / math.pi; var inv_radian = math.pi / 180; var units = {'%': 1, 'px' : 0}; /*========== dom methods ==========*/ function ge
telembyid(id) { return document.ge
telementbyid(id); } function allowdropevent(e) { e.preventdefault(); } function createclasselement(tag, classname, parent) { var elem = document.createelement(tag); elem.classname = classname; if (parent) parent.appendchild(elem); return elem; }; function trackmouse(elem, callback, startfunc, endfunc) { startfunc = startfunc || function(e) {}; ...
...And 4 more matches
The HTML autocomplete attribute - HTML: Hypertext Markup Language
"
tel" a full
telephone number, including the country code.
... if you need to break the phone number up into its components, you can use these values for those fields: "
tel-country-code" the country code, such as "1" for the united states, canada, and other areas in north america and parts of the caribbean.
... "
tel-national" the entire phone number without the country code component, including a country-internal prefix.
...And 4 more matches
<input type="file"> - HTML: Hypertext Markup Language
events change and input supported common attributes required additional attributes accept, capture, files, multiple idl attributes files and value dom interface htmlinpu
telement properties properties that apply only to elements of type file methods select() value a file input's value attribute contains a domstring that represents the path to the selected file(s).
...the other files can be identified using the input's htmlinpu
telement.files property.
...see htmlinpu
telement.webkitdirectory for additional details and examples.
...And 4 more matches
HTML documentation index - HTML: Hypertext Markup Language
classes allow css and javascript to select and access specific elements via the class selectors or functions like the dom method document.ge
telementsbyclassname.
... 67 <bdi>: the bidirectional isolate element bdi, bidi, directionality, element, html, html text-level semantics, html:flow content, html:palpable content, html:phrasing content, internationalization, left-to-right, reference, right-to-left, text, web, direction, i18n, ltr, rtl the html bidirectional isolate element (<bdi>)
tells the browser's bidirectional algorithm to treat the text it contains in isolation from its surrounding text.
...hidden inputs are comple
tely invisible in the rendered page, and there is no way to make it visible in the page's content.
...And 4 more matches
Cross-Origin Resource Sharing (CORS) - HTTP
cross-origin resource sharing (cors) is a mechanism that uses additional http headers to
tell browsers to give a web application running at one origin, access to selected resources from a different origin.
...c-data/'; xhr.open('get', url); xhr.onreadystatechange = somehandler; xhr.send(); this performs a simple exchange between the client and the server, using cors headers to handle the privileges: let's look at what the browser will send to the server in this case, and let's see how the server responds: get /resources/public-data/ http/1.1 host: bar.other user-agent: mozilla/5.0 (macintosh; in
tel mac os x 10.14; rv:71.0) gecko/20100101 firefox/71.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip,deflate connection: keep-alive origin: https://foo.example the request header of note is origin, which shows that the invocation is coming from https://foo.example.
...the first exchange is the preflight request/response: options /doc http/1.1 host: bar.other user-agent: mozilla/5.0 (macintosh; in
tel mac os x 10.14; rv:71.0) gecko/20100101 firefox/71.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip,deflate connection: keep-alive origin: http://foo.example access-control-request-method: post access-control-request-headers: x-pingother, content-type http/1.1 204 no content date: mon, 01 dec 2008 01:15:39 gmt server...
...And 4 more matches
HTTP Index - HTTP
http is a sta
teless protocol, meaning that the server does not keep any data (state) between two requests.
... 20 cross-origin resource sharing (cors) ajax, cors, cross-origin resource sharing, fetch, fetch api, http, http access controls, same-origin policy, security, xmlhttprequest, l10n:priority cross-origin resource sharing (cors) is a mechanism that uses additional http headers to
tell browsers to give a web application running at one origin, access to selected resources from a different origin.
... 41 http public key pinning (hpkp) guide, hpkp, http, security http public key pinning (hpkp) is a security feature that
tells a web client to associate a specific cryptographic public key with a certain web server to decrease the risk of mitm attacks with forged certificates.
...And 4 more matches
Autoplay guide for media and Web Audio APIs - Web media technologies
automatically starting the playback of audio (or videos with audio tracks) immedia
tely upon page load can be an unwelcome surprise to users.
... autoplay availability as a general rule, you can assume that media will be allowed to autoplay only if at least one of the following is true: the audio is muted or its volume is set to 0 the user has interacted with the site (by clicking, tapping, pressing keys, etc.) if the site has been whi
telisted; this may happen either automatically if the browser determines that the user engages with media frequently, or manually through preferences or other user interface features if the autoplay feature policy is used to grant autoplay support to an <iframe> and its document.
...the exact situations that result in blocking, and the specifics of how sites become whi
telisted vary from browser to browser, but the above are good guidelines to go by.
...And 4 more matches
panel - Archive of obsolete content
var textarea = document.ge
telementbyid("edit-box"); textarea.addeventlistener('keyup', function onkeyup(event) { if (event.keycode == 13) { // remove the newline.
...var textarea = document.ge
telementbyid("edit-box"); textarea.addeventlistener('keyup', function onkeyup(event) { if (event.keycode == 13) { // remove the newline.
...this may take one of the following values: "start": load content scripts immedia
tely after the document element for the panel is inserted into the dom, but before the dom content itself has been loaded "ready": load content scripts once dom content has been loaded, corresponding to the domcontentloaded event "end": load content scripts once all the content (dom, js, css, images) for the panel has been loaded, at the time the window.onload event fires this pro...
...And 3 more matches
ui/frame - Archive of obsolete content
// city-info.js var cityselector = window.document.ge
telementbyid("city-selector"); cityselector.addeventlistener("change", citychanged); function citychanged() { window.parent.postmessage(cityselector.value, "*"); } to listen for these messages in the main add-on code, you can assign a listener to the frame's message event.
... var toolbar = toolbar({ name: "city-info", title: "city info", items: [frame] }); function updateweather(location) { frame.postmessage(weather[location], frame.url); } to listen to these messages in the frame script, add a listener to the window's message event: window.addeventlistener("message", updateweather, false); function updateweather(message) { var label = window.document.ge
telementbyid("weather"); label.textcontent = message.data; } from add-on to a specific frame you can send a message from the main add-on code to the frame hosted by a particular browser window.
...if you send a json object, the sdk takes care of serializing and deserializing it for you: // frame.js var label = window.document.ge
telementbyid("linky"); label.addeventlistener("click", function() { window.parent.postmessage({ "type" : "ping", "reason" : "they clicked me" }, "*"); }, true); // main.js var { frame } = require("sdk/ui/frame"); var frame = new frame({ url: "./frame.html" }); frame.on("message", pong); function pong(e) { if (e.data.type == "ping") { console.log(e.data.reason); e.source...
...And 3 more matches
HTML to DOM - Archive of obsolete content
function htmlparser(ahtmlstring){ var html = document.implementation.createdocument("http://www.w3.org/1999/xhtml", "html", null), body = document.createelementns("http://www.w3.org/1999/xhtml", "body"); html.documen
telement.appendchild(body); body.appendchild(components.classes["@mozilla.org/feed-unescapehtml;1"] .getservice(components.interfaces.nsiscriptableunescapehtml) .parsefragment(ahtmlstring, false, null, body)); return body; } it works by creating a content-level (this is safer than chrome-level) <div> in the current page, then parsing the html fragment and attaching that fragment to th...
...the returned <body> object is of type element here is a sample that counts the number of paragraphs in a string: var dompars = htmlparser('<p>foo</p><p>bar</p>'); alert(dompars.ge
telementsbytagname('p').length); if htmlparser() returns the element name html (instead of body), you have all document object with its complete functions list, therefore you can retrieve info within div tag like this: var dompars = htmlparser("<div id='userinfo'>john was a mediocre programmer, but people liked him <strong>anyway</strong>.</div>"); alert(dompars.ge
telementbyid('userinfo').innerhtml); to parse a complete html page, load it into an iframe whose type is content (not chrome).
...for that matter, we're going to load our html document first: var request = xmlhttprequest(); request.open("get", "http://example.org/file.html", false); request.send(null); our next step is to create the document object that will represent the dom into which we'll insert our newly-retrieved html: var doc = document.implementation.createhtmldocument("example"); doc.documen
telement.innerhtml = request.responsetext; after this any manipulation that we might want to do will be something as simple as the following: doc.body.textcontent = "this is inside the body!"; using a hidden iframe element to parse html to a window's dom sample code may need more work.
...And 3 more matches
Sidebar - Archive of obsolete content
to access your sidebar's window or document objects, you need to use the contentwindow or contentdocument properties of document.ge
telementbyid("sidebar") respectively.
... for example the code below calls a function defined in the sidebar's context: var sidebarwindow = document.ge
telementbyid("sidebar").contentwindow; // verify that our sidebar is open at this moment: if (sidebarwindow.location.href == "chrome://yourextension/content/whatever.xul") { // call "yournotificationfunction" in the sidebar's context: sidebarwindow.yournotificationfunction(anyarguments); } testing which sidebar is open the sidebar content may contain different panels (bookmarks, history, webpanel, etc.) and sometimes one wants to only act on the sidebar when it contains a specific panel.
... the good practice to determine which sidebar is open at a time is by testing in location property, which is a chrome url: var sidebarwindow = document.ge
telementbyid("sidebar").contentwindow; if (sidebarwindow.location.href == "chrome://yourextension/content/whatever.xul") { // act on the sidebar content } for example to test if the web panel from firefox is open: var sidebarwindow = document.ge
telementbyid("sidebar").contentwindow; if (sidebarwindow.location.href == "chrome://browser/content/web-panels.xul") { // act on the sidebar content only if it is the web panels } accessing the browser.xul window from a sidebar script see accessing the elements of the top-level document from a child window section of working with windows in chrome code.
...And 3 more matches
Install Manifests - Archive of obsolete content
2 extensions 4 themes 8 locale 32 multiple item package 64 spell check dictionary 128
telemetry experiment 256 webextension experiment examples <em:type>2</em:type> this property was added for firefox 1.5, and is only required for add-on types other than extensions and themes.
... examples <em:abouturl>chrome://myext/content/about.xul</em:abouturl> bootstrap a boolean value that
tells the application whether the extension is boot-strappable.
... skinnable a true or false value property that
tells the application whether the (complete) theme can be skinned by lightweight themes/personas: examples <em:skinnable>true</em:skinnable> strictcompatibility a boolean value indicating if the add-on should be enabled when the version of the application is greater than its max version.
...And 3 more matches
JavaScript Client API - Archive of obsolete content
wipe() when this method is called, your store needs to comple
tely wipe all of its stored data from the local application.
... create(record) not to be confused with createrecord(), this method (which should probably be renamed for clarity soon)
tells your store to create a new item in the local application, based on the data in record.
... update(record) the argument is a record which has been remo
tely modified; your store should locate the matching local item (presumably using the guid, which is available in record.id) and update it to the new values provided in record.
...And 3 more matches
Venkman Introduction - Archive of obsolete content
starting the debugger the javascript debugger is automatically pre-installed in mozilla 1.x but must be installed separa
tely in firefox and other gecko-based products, such as thunderbird and netscape 7.x.
... fortuna
tely, the xpinstall technology makes it possible to install new application modules in firefox by just clicking a hyperlink.
... stop button waiting for execution also note that when you are currently executing javascript and click the stop button, the javascript stops immedia
tely.
...And 3 more matches
MenuModification - Archive of obsolete content
<script> function addtomenu() { var menu = document.ge
telementbyid("edit-menu"); menu.appenditem("insert", "insert"); } </script> <menu id="edit-menu"/> <button label="add" oncommand="addtomenu()"/> in this example, the addtomenu function is called when the button is pressed.
... <script> function addsubmenu() { var popup = document.ge
telementbyid("file-popup"); var newmenu = document.createelement("menu"); popup.appendchild(newmenu); newmenu.label = "new"; newmenu.appenditem("document", "doc"); newmenu.appenditem("image", "image"); } </script> <menu label="file" onpopupshowing="addsubmenu()"> <menupopup id="file-popup"/> </menu>.
...then add menuitem to menupopup (all with appendchild to their paren
telement).
...And 3 more matches
Modifying a XUL Interface - Archive of obsolete content
for example, the following will add a button to a xul window: example 1 : source view <script> function addbutton(){ var abox = document.ge
telementbyid("abox"); var button = document.createelement("button"); button.setattribute("label","a new button"); abox.appendchild(button); } </script> <box id="abox" width="200"> <button label="add" oncommand="addbutton();"/> </box> this example has two parts a box container element in xul.
... the button element has two attributes "label" and "oncommand" a javascript function named "addbutton()" this script first gets a reference to the box with ge
telementbyid(), which is the container to add a new button to.
... the function ge
telementbyid() does not know that the box it is looking for happens to be containing the tag that has the oncommand attribute that referenced it.
...And 3 more matches
Using Remote XUL - Archive of obsolete content
however, there is a whi
telist that lets you specify sites that can still use remote xul.
... the remote xul manager extension lets you manage this whi
telist, which is maintained using nsipermissionmanager, by creating entries of type "allowxulxbl", like this: components.classes["@mozilla.org/permissionmanager;1"] .getservice(components.interfaces.nsipermissionmanager) .add(uri, 'allowxulxbl', components.interfaces.nsipermissionmanager.allow_action); xul (pronounced like "zool"), which is short for xml-based user interface language, is an xml-based language for describing application interfaces.
...for apache, you can do this by adding the following line to your mime.types file: application/vnd.mozilla.xul+xml .xul alterna
tely, add this line to your httpd.conf file or, if the apache server is configured to allow it, to the .htaccess file in the directory from which the xul file is served: addtype application/vnd.mozilla.xul+xml .xul then restart your web server.
...And 3 more matches
XUL Questions and Answers - Archive of obsolete content
unfortuna
tely, no simple solution to this was posted.
...an example of this is: var tree = document.ge
telementbyid('treeid'); selectedtreeitem = tree.view.getitematindex(tree.currentindex); selectedtreeitem.firstchild.setattribute('style', 'background: #ff0000'); what is an example of tab browser in xul?
... using the following code sample, // get browsers object var browsers=document.ge
telementbyid('content').browsers; var numbrowsers=browsers.length; for (var i=0; numbrowsers>i; i++) { var thisuri=browsers[i].currenturi.spec; // do something with it.
...And 3 more matches
prefwindow - Archive of obsolete content
on platforms where the convention is to apply changes immedia
tely, the preferences are adjusted as soon as the user interface element is changed.
...a true value for this preference makes the preference window apply immedia
tely the user choices, without waiting for the dialog to close with ok.
...if it is set to true any changes to settings are supposed to be applied immedia
tely.
...And 3 more matches
What is RSS - Archive of obsolete content
(although rdf-based rss formats exist, namely the deprecated rss 0.90 and rss 1.0.) common uses of rss syndication are for the syndication of news web sites, of blogs, of internet radio, and of internet
television.
...syndication is the process of
telling others that you have content for them to consume.
... in other words, when you syndicate, you are
telling everyone something like: "hey everyone, i've got articles that i want everyone to come and read.
...And 3 more matches
Using the W3C DOM - Archive of obsolete content
accessing elements with the w3c dom the basic method for referencing elements in an html page is document.ge
telementbyid().
...for example, the following short sample dynamically sets the left margin of a <div> element with an id of "inset" to half an inch: // in the html: <div id="inset">sample text</div> document.ge
telementbyid("inset").style.marginleft = ".5in"; note: internet explorer 5 through 7 have a flawed implementation of ge
telementbyid(), which returns the first element with a matching name or id (id versus name when using ge
telementbyid, msdn: ge
telementbyid method).
... ie-specific ways to access elements w3c web standards replacements id_attribute_value document.ge
telementbyid() document.all.id_attribute_value document.ge
telementbyid() document.all[id_attribute_value] document.ge
telementbyid() formname.inputname.value document.forms["formname"].inputname.value or document.forms["formname"].elements["inputname"].value inputname.value document.forms["formname"].inputname.value or document.forms["formname"].elements["inputname"].value formctrlname document.forms["formname"].formctrlname or document.forms["formname"].elements["formctrlname"] document.forms(0) document.forms[0] more on accessing forms and form elements: referencing forms and form...
...And 3 more matches
ArrayBuffer.transfer() - Archive of obsolete content
the static arraybuffer.transfer() method returns a new arraybuffer whose contents have been taken from the oldbuffer's data and then is either truncated or zero-extended by newby
telength.
... if newby
telength is undefined, the by
telength of the oldbuffer is used.
... syntax arraybuffer.transfer(oldbuffer [, newby
telength]); parameters oldbuffer an arraybuffer object from which to transfer.
...And 3 more matches
Legacy layout methods - Learn web development
cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...curabitur vehicula
tellus neque, ac ornare ex malesuada et.
...cras porttitor imperdiet nunc, at ultricies
tellus laoreet sit amet.
...And 3 more matches
Advanced form styling - Learn web development
unfortuna
tely, the behavior of this property's original implementations was very different across browsers, making it not very usable.
...however, in the case of the number type the data being collected is simpler, and it is easy to just use a text input type instead if desired (or
tel if you want mobile browsers to show the numeric keypad).
...you can use something like the following to remove the default slider track comple
tely and replace it with a custom style (a thin red track, in this case): input[type="range"] { appearance: none; -webkit-appearance: none; background: red; height: 2px; padding: 0; outline: 1px solid transparent; } however, it is very difficult to customize the style of the range control's drag handle — to get full control over range styling you'll need to use a whole bunch of complex css code, including multiple non-standard, browser-specific pseudo-elements.
...And 3 more matches
Debugging HTML - Learn web development
note: html is parsed permissively because when the web was first created, it was decided that allowing people to get their content published was more important than making sure the syntax was absolu
tely correct.
...this demo is delibera
tely written with some built-in errors for us to explore (the html markup is said to be badly-formed, as opposed to well-formed).
...you will see something like this: this immedia
tely doesn't look great; let's look at the source code to see if we can work out why (only the body contents are shown): <h1>html debugging examples</h1> <p>what causes errors in html?
...And 3 more matches
Video and audio content - Learn web development
fortuna
tely, a few years later the html5 specification had such features added, with the <video> and <audio> elements, and some shiny new javascript apis for controlling them.
... we won't be teaching you how to produce audio and video files — that requires a comple
tely different skillset.
...fortuna
tely, there are things you can do to help prevent this from being a problem.
...And 3 more matches
Client-side storage - Learn web development
however, this does not mean cookies are comple
tely useless on the modern-day web — they are still used commonly to store data related to user personalization and state, e.g.
... next, add the following to the bottom of your code: window.onload = function() { }; we will write all of our subsequent code inside this window.onload event handler function, called when the window's load event fires, to make sure we don't try to use indexeddb functionality before the app has comple
tely finished loading (it could fail if we don't).
...you don't want to hang the browser while you wait for the results, so database operations are asynchronous, meaning that instead of happening immedia
tely, they will happen at some point in the future, and you get notified when they're done.
...And 3 more matches
Framework main features - Learn web development
the curly braces around subject on line 4
tell the application to read the value of the subject constant and insert it into our <h1>.
... when used with react, the jsx from the previous snippet would be compiled into this: var subject = "world"; var header = react.createelement("header", null, react.createelement("h1", null, "hello, ", subject, "!") ); when ultima
tely rendered by the browser, the above snippet will produce html that looks like this: <header> <h1>hello, world!</h1> </header> handlebars the handlebars templating language is not specific to ember applications, but it is heavily utilized in ember apps.
...this data can be used influence the html that an application ultima
tely builds.
...And 3 more matches
React interactivity: Events and state - Learn web development
previous overview: client-side javascript frameworks next with our component plan worked out, it's now time to start updating our app from a comple
tely static ui to one that actually allows us to interact and change things.
... the onclick attribute has special meaning here: it
tells react to run a given function when the user clicks on the button.
... we want our handlesubmit() function to ultima
tely help us create a new task, so we need a way to pass information from <form /> to <app />.
...And 3 more matches
Introduction to automated testing - Learn web development
fortuna
tely, there are tools to help us automate some of this pain away.
...commercial cross-browser testing apps like lambdatest, sauce labs, browserstack, and testingbot are based on selenium, but allow you to access their set up remo
tely using a simple interface, saving you the hassle of setting up your own testing system.
... when loading has finished, you can then start to remo
tely test the web site running in the chosen browser.
...And 3 more matches
JNI.jsm
working with arrays creating/preallocating a typed array methods cdata .get(number aindex); cdata .ge
telements(number astart, number alength); void .set(number aindex, cdata avalue); void .se
telements(number astart, [array, size_is(arr.length > number anynumber > 0)] in cdata avalsarray); .get() gets the value of the element in the array at given aindex.
... .ge
telements() returns a new cdata object of the section of the array specified by astart and ending at position astart + alength.
... void se
telements(number astart, number alength); parameters astart the position to start setting elements of the array in.
...And 3 more matches
L10n Checks
locale (en-us) by setting the -r parameter, e.g.: check-l10n-completeness -r pl browser/locales/l10n.ini ../l10n/ de output mode you can change the look and feel of the output by setting the -o parameter to 0 (tree; default), 1 (full tree) or 2 (full relative paths), e.g.: check-l10n-completeness -o 2 browser/locales/l10n.ini ../l10n/ de en-us in the locale directory in the source mode you can
tell l10n checks to look for the en-us locale in the directory containing all other locales instead of the directory containing the source by setting the -l parameter (useful for e.g.
... "kompozer"), e.g.: check-l10n-completeness -l browser/locales/l10n.ini ../l10n/ de compare every directory in the source mode you can
tell l10n checks to compare every directory, not only the ones set in the all-locales file, by setting the -f parameter (useful for e.g.
... "seamonkey" with its extensions), e.g.: check-l10n-completeness -f suite/locales/l10n.ini ../l10n/ de test the reference locale in the source mode you can
tell l10n checks to also check the reference locale, by setting the -e parameter (requires the -a parameter to be set too), e.g.: check-l10n-completeness -a 1 -e suite/locales/l10n.ini ../l10n/ de turbo mode in the source mode you can
tell l10n checks to look only for missing and obsolete entities and files, by setting the -t parameter, e.g.: check-l10n-completeness -t suite/locales/l10n.ini ../l10n/ de check access keys in all modes you can
tell l10n checks to check if the access keys are set properly, by setting the -a parameter, e.g.: check-l10n-completeness -a 1 suite/locales/l10n.ini ../l10n/ de there are three modes available: ...
...And 3 more matches
NSS environment variables
see nss tracing 3.12 nss_use_decoded_cka_ec_point boolean (any value to enable)
tells nss to send ec key points across the pkcs#11 interface in the non-standard unencoded format that was used by default before nss 3.12.3.
... 3.12.3 nss_use_shexp_in_cert_name boolean (any value to enable)
tells nss to allow shell-style wildcard patterns in certificates to match ssl server host names.
... before 3.0 ns_use_gcc boolean (1 to enable) on systems where gcc is not the default compiler, this
tells nss to build with gcc.
...And 3 more matches
Redis Tips
it is intended primarily for developers, and delibera
tely omits some topics that will be important in any redis deployment, like security and backups.
... the redis command watch lets you name keys you're worried about; it causes your next transaction to be immedia
tely aborted if any of the watched keys has been modified by anyone else.
... ok, now in a different shell, and another redis-cli, do this: redis2> rpush myqueue 42 now if you look back at the first redis-cli, you'll see that it immedia
tely popped the value off the list and said something like: redis1> 1) "myqueue" 2) "42" (26.87s) that rules!
...And 3 more matches
Animated PNG graphics
conceptually, at the beginning of each play the output buffer must be comple
tely initialized to a fully transparent black rectangle, with width and height dimensions from the 'ihdr' chunk.
...the default image should be appropria
tely padded with fully transparent pixels if extra space will be needed for later frames.
... num_plays indicates the number of times that this animation should play; if it is 0, the animation should play indefini
tely.
...And 3 more matches
Fun With XBL and XPConnect
<method name="autocomplete"> <argument name="asearchstring"/> <argument name="resultlistener"/> <body> <![cdata[ return this.autocompletesession.autocomplete(null, anonymouscontent[0], asearchstring, this.autocomple
telistener); ]]> </body> </method> you can see that the body of the method is just getting the auto complete session object and calling the auto complete method on it.
...i could apply a trick similar to what i did for the xpcom object: <property name="autocomple
telistener"> <![cdata[ ({ onautocompleteresult: function(aitem, aoriginalstring, amatch) { if ( aitem ) { anonymouscontent[0].value = amatch; } } }) ]]> </property> as long as the js for the value of autocomple
telistener evaluates to an object (and wrapping the expression with a set of parens like i did, does this), then the value of autoco...
...mple
telistener is an object that implements my interface.
...And 3 more matches
Introduction to XPCOM for the DOM
if you haven't grasped it comple
tely, there is no need to read further.
... fortuna
tely, there are nscomptr's to make our life easier.
...to do so, there are two main techniques, and the context should
tell you what to use.
...And 3 more matches
nsISupportsArray
inherits from: nsicollection last changed in gecko 1.7 method overview boolean appendelements(in nsisupportsarray aelements); violates the xpcom interface guidelines nsisupportsarray clone(); void compact(); void deleteelementat(in unsigned long aindex); void dele
telas
telement(in nsisupports aelement); nsisupports elementat(in unsigned long aindex); violates the xpcom interface guidelines boolean enumeratebackwards(in nsisupportsarrayenumfunc afunc, in voidptr adata); violates the xpcom interface guidelines boolean enumerateforwards(in nsisupportsarrayenumfunc afunc, in voidptr adata); violates the xpcom interface guidelines boolean equals([const] in nsisupportsarray other); violat...
...); long getindexofstartingat(in nsisupports apossibleelement, in unsigned long astartindex); long getlastindexof(in nsisupports apossibleelement); long indexof([const] in nsisupports apossibleelement); violates the xpcom interface guidelines long indexofstartingat([const] in nsisupports apossibleelement, in unsigned long astartindex); violates the xpcom interface guidelines boolean inser
telementat(in nsisupports aelement, in unsigned long aindex); violates the xpcom interface guidelines boolean inser
telementsat(in nsisupportsarray aother, in unsigned long aindex); violates the xpcom interface guidelines long lastindexof([const] in nsisupports apossibleelement); violates the xpcom interface guidelines boolean moveelement(in long afrom, in long ato); violates the xpcom interface...
... guidelines boolean removeelementat(in unsigned long aindex); violates the xpcom interface guidelines boolean removeelementsat(in unsigned long aindex, in unsigned long acount); violates the xpcom interface guidelines boolean removelas
telement([const] in nsisupports aelement); violates the xpcom interface guidelines boolean replaceelementat(in nsisupports aelement, in unsigned long aindex); violates the xpcom interface guidelines boolean sizeto(in long asize); violates the xpcom interface guidelines methods violates the xpcom interface guidelines appendelements() boolean appendelements( in nsisupportsarray aelements ); parameters aelements return value clone() nsisupportsarray clone(); parameters none.
...And 3 more matches
Web Console remoting - Firefox Developer Tools
ers, onresponse) the new startlisteners packet: { "to": "conn0.console9", "type": "startlisteners", "listeners": [ "pageerror", "consoleapi", "networkactivity", "fileactivity" ] } the reply is: { "startedlisteners": [ "pageerror", "consoleapi", "networkactivity", "fileactivity" ], "nativeconsoleapi": true, "from": "conn0.console9" } the reply
tells which listeners were started and it includes a flag nativeconsoleapi which
tells if the window.console object was overridden by the scripts in the page or not.
... when page navigation starts the following packet is sent from the tab actor: { "from": tabactor, "type": "tabnavigated", "state": "start", "url": newurl, "nativeconsoleapi": true } the nativeconsoleapi property
tells if the window.console object is native or not for the top level window object for the given tab - this is always true when navigation starts.
... the private flag
tells if the error comes from a private window/tab (added in firefox 24).
...And 3 more matches
Advanced animations - Web APIs
var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var ball = { x: 100, y: 100, radius: 25, color: 'blue', draw: function() { ctx.beginpath(); ctx.arc(this.x, this.y, this.radius, 0, math.pi * 2, true); ctx.closepath(); ctx.fillstyle = this.color; ctx.fill(); } }; ball.draw(); nothing special here, the ball is actually a simple circle and gets drawn with the...
... var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var raf; var ball = { x: 100, y: 100, vx: 5, vy: 2, radius: 25, color: 'blue', draw: function() { ctx.beginpath(); ctx.arc(this.x, this.y, this.radius, 0, math.pi * 2, true); ctx.closepath(); ctx.fillstyle = this.color; ctx.fill(); } }; function draw() { ctx.clearrect(0,0, canvas.width, canvas.height); ...
... <canvas id="canvas" style="border: 1px solid" width="600" height="300"></canvas> var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var raf; var ball = { x: 100, y: 100, vx: 5, vy: 2, radius: 25, color: 'blue', draw: function() { ctx.beginpath(); ctx.arc(this.x, this.y, this.radius, 0, math.pi * 2, true); ctx.closepath(); ctx.fillstyle = this.color; ctx.fill(); } }; function draw() { ctx.clearrect(0,0, canvas.width, canvas.height); ...
...And 3 more matches
Introduction to the DOM - Web APIs
for example, the standard dom specifies that the ge
telementsbytagname method in the code below must return a list of all the <p> elements in the document: const paragraphs = document.ge
telementsbytagname("p"); // paragraphs[0] is the first <p> element // paragraphs[1] is the second <p> element, etc.
...though we focus exclusively on javascript in this reference documentation, implementations of the dom can be built for any language, as this python example demonstrates: # python dom example import xml.dom.minidom as m doc = m.parse(r"c:\projects\py\chap1.xml") doc.nodename # dom property of document object p_list = doc.ge
telementsbytagname("para") for more information on what technologies are involved in writing javascript on the web, see javascript technologies overview.
... when you create a script–whether it's inline in a <script> element or included in the web page by means of a script loading instruction–you can immedia
tely begin using the api for the document or window elements to manipulate the document itself or to get at the children of that document, which are the various elements in the web page.
...And 3 more matches
HTMLImageElement.loading - Web APIs
the htmlimageelement property loading is a string whose value provides a hint to the user agent that
tells the browser how to handle loading images which are currently outside the window's visual viewport.
... this helps to optimize the loading of the document's contents by postponing loading the image until it's expected to be needed, rather than immedia
tely during the initial page load.
...the possible values are: eager the default behavior, eager
tells the browser to load the image as soon as the <img> element is processed.
...And 3 more matches
The HTML DOM API - Web APIs
htmlanchorelement htmlareaelement htmlaudioelement htmlbrelement htmlbaseelement htmlbodyelement htmlbuttonelement htmlcanvaselement htmldlis
telement htmldataelement htmldatalis
telement htmldetailselement htmldialogelement htmldirectoryelement htmldivelement htmlelement htmlembedelement htmlfieldse
telement htmlformelement htmlhrelement htmlheadelement htmlheadingelement htmlhtmlelement htmliframeelement htmlimageelement htmlinpu
telement htmllielement htmllabelelement htmllegendelement htmllinkelement htmlmapelement ...
...htmlmediaelement htmlmenuelement htmlmetaelement htmlmeterelement htmlmodelement htmlolis
telement htmlobjec
telement htmloptgroupelement htmloptionelement htmloutpu
telement htmlparagraphelement htmlparamelement htmlpictureelement htmlpreelement htmlprogresselement htmlquoteelement htmlscrip
telement htmlselec
telement htmlslo
telement htmlsourceelement htmlspanelement htmlstyleelement htmltablecaptionelement htmltablecellelement htmltablecolelement htmltableelement htmltablerowelement htmltablesectionelement htmltemplateelement htmltextareaelement htmltimeelement htmltitleelement htmltrackelement htmlulis
telement htmlunknownelement htmlvideoelement deprecated html element interfaces htmlmarqueeelement obsolete html element interfaces htmlbasefont...
...element htmlfon
telement htmlframeelement htmlframese
telement htmlisindexelement htmlmenuitemelement web app and browser integration interfaces these interfaces offer access to the browser window and document that contain the html, as well as to the browser's state, available plugins (if any), and various configuration options.
...And 3 more matches
Using Pointer Events - Web APIs
function startup() { var el = document.ge
telementsbytagname("canvas")[0]; el.addeventlistener("pointerdown", handlestart, false); el.addeventlistener("pointerup", handleend, false); el.addeventlistener("pointercancel", handlecancel, false); el.addeventlistener("pointermove", handlemove, false); log("initialized."); } this simply sets up all the event listeners for our <canvas> element so we can handle the touch events as they oc...
... function handlestart(evt) { log("pointerdown."); var el = document.ge
telementsbytagname("canvas")[0]; var ctx = el.getcontext("2d"); log("pointerdown: id = " + evt.pointerid); ongoingtouches.push(copytouch(evt)); var color = colorfortouch(evt); ctx.beginpath(); ctx.arc(touches[i].pagex, touches[i].pagey, 4, 0, 2 * math.pi, false); // a circle at the start ctx.arc(evt.clientx, evt.clienty, 4, 0, 2 * math.pi, false); // a circle at the start ctx.fillstyle = color; ctx.fill(); } after storing some of the event's processing in th...
... function handlemove(evt) { var el = document.ge
telementsbytagname("canvas")[0]; var ctx = el.getcontext("2d"); var color = colorfortouch(evt); var idx = ongoingtouchindexbyid(evt.pointerid); log("continuing touch: idx = " + idx); if (idx >= 0) { ctx.beginpath(); log("ctx.moveto(" + ongoingtouches[idx].pagex + ", " + ongoingtouches[idx].pagey + ");"); ctx.moveto(ongoingtouches[idx].pagex, ongoingtouches[idx].pagey); log...
...And 3 more matches
Using Service Workers - Web APIs
read jake archibald's (unfortuna
tely-titled but well-written) application cache is a douchebag for more details.
...if you just passed in the url, and then tried to access the other items in the json separa
tely when the for() loop is being iterated through later on, it wouldn’t work, as the promise wouldn’t resolve at the same time as the iterations are being done (that is a synchronous process.) we actually resolve the promise with an array, as we want to make the loaded image blob available to the resolving function later on in the code, but also the image name, credits and alt text (see app.js ...
...it persists until you
tell it not to — again, you have full control.
...And 3 more matches
TextRange - Web APIs
this property should only be used as one of the solutions when you need to be compatible with lower versions of ie, rather than relying on it comple
tely in cross browser scripts.
... textrange.boundingleftread only returns the distance between the left edge of the rectangle that binds the textrange object and the left edge that comple
tely contains the textrange object.
... textrange.boundingtopread only returns the distance between the top edge of the rectangle that binds the textrange object and the top edge that comple
tely contains the textrange object.
...And 3 more matches
Touch events - Web APIs
function startup() { var el = document.ge
telementbyid("canvas"); el.addeventlistener("touchstart", handlestart, false); el.addeventlistener("touchend", handleend, false); el.addeventlistener("touchcancel", handlecancel, false); el.addeventlistener("touchmove", handlemove, false); } document.addeventlistener("domcontentloaded", startup); this simply sets up all the event listeners for our <canvas> element so we can handle the touch...
... function handlestart(evt) { evt.preventdefault(); console.log("touchstart."); var el = document.ge
telementbyid("canvas"); var ctx = el.getcontext("2d"); var touches = evt.changedtouches; for (var i = 0; i < touches.length; i++) { console.log("touchstart:" + i + "..."); ongoingtouches.push(copytouch(touches[i])); var color = colorfortouch(touches[i]); ctx.beginpath(); ctx.arc(touches[i].pagex, touches[i].pagey, 4, 0, 2 * math.pi, false); // a circle at the start ctx.fillstyle = color; ctx.fill(); con...
... function handlemove(evt) { evt.preventdefault(); var el = document.ge
telementbyid("canvas"); var ctx = el.getcontext("2d"); var touches = evt.changedtouches; for (var i = 0; i < touches.length; i++) { var color = colorfortouch(touches[i]); var idx = ongoingtouchindexbyid(touches[i].identifier); if (idx >= 0) { console.log("continuing touch "+idx); ctx.beginpath(); console.log("ctx.moveto(" + ongoingtouches[idx].pagex + ", " + ongo...
...And 3 more matches
WebGLRenderingContext.vertexAttribPointer() - Web APIs
if stride is 0, the attribute is assumed to be tightly packed, that is, the attributes are not interleaved but each attribute is in a separate block, and the next vertex' attribute follows immedia
tely after the current vertex.
...also, we have to call gl.enablevertexattribarray() to
tell webgl that this attribute should be filled with data from our array buffer.
...for highest performance, interleave the attributes and use the smallest data type that still accura
tely represents your geometry.
...And 3 more matches
Using textures in WebGL - Web APIs
// until then put a single pixel in the texture so we can // use it immedia
tely.
...this makes the texture immedia
tely usable as a solid blue color even though it may take a few moments for our image to download.
... first, the code to specify the colors buffer is gone, replaced with this: //
tell webgl how to pull out the texture coordinates from buffer { const num = 2; // every coordinate composed of 2 values const type = gl.float; // the data in the buffer is 32 bit float const normalize = false; // don't normalize const stride = 0; // how many bytes to get from one set to the next const offset = 0; // how many bytes inside the buffer to start from gl.bindbuffer...
...And 3 more matches
WebGL best practices - Web APIs
flush when expecting results (like queries or rendering frame completion) flush
tells the implementation to push all pending commands out for execution, flushing them out of the queue, instead of waiting for more commands to enqueue before sending for execution.
...} this technique may not work in all applications, for example those which require programs to be immedia
tely available for rendering.
... if you know your precision requirements, getshaderprecisionformat() will
tell you what the system supports.
...And 3 more matches
WebGL model view projection - Web APIs
these composed matrices ultima
tely move the original model data around into a special coordinate space called clip space.
... webglbox constructor the constructor looks like this: function webglbox() { // setup the canvas and webgl context this.canvas = document.ge
telementbyid('canvas'); this.canvas.width = window.innerwidth; this.canvas.height = window.innerheight; this.gl = mdn.createcontext(canvas); var gl = this.gl; // setup a webgl program, anything part of the mdn object is defined outside of this article this.webglprogram = mdn.createwebglprogramfromids(gl, 'vertex-shader', 'fragment-shader'); gl.useprogram(this.webglprogram); // save...
... the attribute and uniform locations this.positionlocation = gl.getattriblocation(this.webglprogram, 'position'); this.colorlocation = gl.getuniformlocation(this.webglprogram, 'color'); //
tell webgl to test the depth when drawing, so if a square is behind // another square it won't be drawn gl.enable(gl.depth_test); } webglbox draw now we'll create a method to draw a box on the screen.
...And 3 more matches
Establishing a connection: The WebRTC perfect negotiation pattern - Web APIs
perfect negotiation concepts perfect negotiation makes it possible to seamlessly and comple
tely separate the negotiation process from the rest of your application's logic.
... the process of sending an offer, and making use of the updated setlocaldescription() method: let makingoffer = false; pc.onnegotiationneeded = async () => { try { makingoffer = true; await pc.setlocaldescription(); signaler.send({ description: pc.localdescription }); } catch(err) { console.error(err); } finally { makingoffer = false; } }; we set makingoffer immedia
tely before calling setlocaldescription() in order to lock against interfering with sending this offer, and we don't clear it back to false until the offer has been sent to the signaling server (or an error has occurred, preventing the offer from being made).
...wer()); signaler.send({ description: pc.localdescription }); } } else if (candidate) { try { await pc.addicecandidate(candidate); } catch(err) { if (!ignoreoffer) { throw err; } } } } catch(err) { console.error(err); } }; since rollback works by postponing changes until the next negotiation (which will begin immedia
tely after the current one is finished), the polite peer needs to know when it needs to throw away a received offer if it's currently waiting for a reply to an offer it's already sent.
...And 3 more matches
Writing WebSocket client applications - Web APIs
if you want to open a connection and are flexible about the protocols you support, you can specify an array of protocols: var examplesocket = new websocket("wss://www.example.com/socketserver", ["protocolone", "protocoltwo"]); once the connection is established (that is, readystate is open), examplesocket.protocol will
tell you which protocol the server selected.
... as establishing a connection is asynchronous and prone to failure there is no guarantee that calling the send() method immedia
tely after creating a websocket object will be successful.
... var msg = { type: "message", text: document.ge
telementbyid("text").value, id: clientid, date: date.now() }; // send the msg object as a json-formatted string.
...And 3 more matches
Writing a WebSocket server in C# - Web APIs
here's a barebones server implementation: using system.net.sockets; using system.net; using system; class server { public static void main() { tcplistener server = new tcplistener(ipaddress.parse("127.0.0.1"), 80); server.start(); console.wri
teline("server has started on 127.0.0.1:80.{0}waiting for a connection...", environment.newline); tcpclient client = server.accepttcpclient(); console.wri
teline("a client connected."); } } tcpclient methods: system.net.sockets.networkstream getstream() gets the stream which is the communication channel.
... tcpclient client = server.accepttcpclient(); console.wri
teline("a client connected."); networkstream stream = client.getstream(); //enter to an infinite cycle to be able to handle every change in stream while (true) { while (!stream.dataavailable); byte[] bytes = new byte[client.available]; stream.read(bytes, 0, bytes.length); } handshaking when a client connects to a server, it sends a get request to upgrade the connection to a websocke...
...); } put together wsserver.cs // // csc wsserver.cs // wsserver.exe using system; using system.net; using system.net.sockets; using system.text; using system.text.regularexpressions; class server { public static void main() { string ip = "127.0.0.1"; int port = 80; var server = new tcplistener(ipaddress.parse(ip), port); server.start(); console.wri
teline("server has started on {0}:{1}, waiting for a connection...", ip, port); tcpclient client = server.accepttcpclient(); console.wri
teline("a client connected."); networkstream stream = client.getstream(); // enter to an infinite cycle to be able to handle every change in stream while (true) { while (!stream.dataavailable); while ...
...And 3 more matches
Rendering and the WebXR frame animation callback - Web APIs
this is important because as the computer becomes increasingly busy, it may not be able to accura
tely call your callback every frame and may have to skip frames.
... fortuna
tely, you can easily compute how much time you're allowed to use between frames as 1/refreshrate seconds.
... fortuna
tely, there are some tricks you can use to further reduce your impact and optimize performance if your renderering needs are particularly heavy.
...And 3 more matches
WindowOrWorkerGlobalScope.setInterval() - Web APIs
<!doctype html> <html> <head> <meta charset="utf-8" /> <title>setinterval/clearinterval example</title> <script> var nintervid; function changecolor() { nintervid = setinterval(flashtext, 1000); } function flashtext() { var oelem = document.ge
telementbyid('my_box'); oelem.style.color = oelem.style.color == 'red' ?
...quisque in ante
tellus, in placerat est.
...pellentesque dapibus
tellus ut ipsum aliquam eu auctor dui vehicula.
...And 3 more matches
Cubic Bezier Generator - CSS: Cascading Style Sheets
="updatecanvas();return true;" type="text" maxlength=6 id="x2" value="0.14" class='field'> <label for="y2">y2 = </label><input onchange="updatecanvas();return true;" type="text" maxlength=6 id="y2" value="0.53" class='field'> <br> <output id="output">log</output> </form> </html> .field { width: 40px; } function updatecanvas() { var x1 = document.ge
telementbyid('x1').value; var y1 = document.ge
telementbyid('y1').value; var x2 = document.ge
telementbyid('x2').value; var y2 = document.ge
telementbyid('y2').value; drawbeziercurve(x1, y1, x2, y2); } const radius = 4; // place needed to draw the rulers const rulers = 30.5; const margin = 10.5; const basic_scale_size = 5; // size of 0.1 tick on the rulers var scaling; //limitation: sc...
...aling is computed once: if canvas.height/canvas.width change it won't be recalculated var dragsm = 0; // drag state machine: 0 = nodrag, others = object being dragged function initcanvas() { // get the canvas element using the dom var canvas = document.ge
telementbyid('bezier'); // make sure we don't execute when canvas isn't supported if (canvas.getcontext) { // use getcontext to use the canvas for drawing var ctx = canvas.getcontext('2d'); scaling = math.min(canvas.height - rulers - margin, canvas.width - rulers - margin); canvas.onmousedown = mousedown; canvas.onmouseup = mouseup; } else { alert('you need safari or firefox 1.5+ to see this demo.'); } } function cx(x) { return x * scaling + rulers; } function r...
...result + 0.5 : result; } function drawbeziercurve(x1, y1, x2, y2) { // get the canvas element using the dom var canvas = document.ge
telementbyid('bezier'); // make sure we don't execute when canvas isn't supported if (canvas.getcontext) { // use getcontext to use the canvas for drawing var ctx = canvas.getcontext('2d'); // clear canvas ctx.clearrect(0, 0, canvas.width, canvas.height); // draw the rulers ctx.beginpath(); ctx.strokestyle = "black"; // dr...
...And 3 more matches
<color> - CSS: Cascading Style Sheets
there are a few caveats to consider when using color keywords: html only recognizes the 16 basic color keywords found in css1, using a specific algorithm to convert unrecognized values (often to comple
tely different colors).
... unlike html, css will comple
tely ignore unknown keywords.
...this makes the background behind the colored item comple
tely visible.
...And 3 more matches
Adding captions and subtitles to HTML5 video - Developer guides
this example uses an excerpt from the sin
tel open movie, created by the blender foundation.
... in this example we are using a different video, sin
tel, as it actually has some speech in it and therefore is better for illustrating how subtitles work!
...we actually have our subtitles in three different languages — english, german, and spanish — so we will reference all three of the relevant vtt files by adding <track> elements inside our html5 <video> element: <video id="video" controls preload="metadata"> <source src="video/sin
tel-short.mp4" type="video/mp4"> <source src="video/sin
tel-short.webm" type="video/webm"> <track label="english" kind="subtitles" srclang="en" src="captions/vtt/sin
tel-en.vtt" default> <track label="deutsch" kind="subtitles" srclang="de" src="captions/vtt/sin
tel-de.vtt"> <track label="español" kind="subtitles" srclang="es" src="captions/vtt/sin
tel-es.vtt"> </video> as you can see, each ...
...And 3 more matches
<input type="password"> - HTML: Hypertext Markup Language
if the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored comple
tely.
...its value can, however, still be changed from javascript code that directly sets the value of the htmlinpu
telement.value property.
...it only specifies approxima
tely how many can be seen at a time.
...And 3 more matches
<input type="search"> - HTML: Hypertext Markup Language
you can retrieve this using the htmlinpu
telement.value property in javascript.
... if the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored comple
tely.
...its value can, however, still be changed by javascript code directly setting the htmlinpu
telement.value property.
...And 3 more matches
Using the application cache - HTML: Hypertext Markup Language
in firefox, the offline cache data is stored separa
tely from the firefox profile—next to the regular disk cache: windows vista/7: c:\users\<username>\appdata\local\mozilla\firefox\profiles\<salt>.<profile name>\offlinecache mac/linux: /users/<username>/library/caches/firefox/profiles/<salt>.<profile name>/offlinecache in firefox the current status of the offline cache can be inspected on the about:cache page (under the "offline cache device" ...
...the offline cache can be cleared for each site separa
tely using the "remove..." button in tools -> options -> advanced -> network -> offline data.
...files listed under the cache: section header (or immedia
tely after the cache manifest line) are explicitly cached after they're downloaded for the first time.
...And 3 more matches
Using HTTP cookies - HTTP
typically, it's used to
tell if two requests came from the same browser — keeping a user logged-in, for example.
... it remembers stateful information for the sta
teless http protocol.
...a simple cookie is set like this: set-cookie: <cookie-name>=<cookie-value> this shows the server sending headers to
tell the client to store a pair of cookies: http/2.0 200 ok content-type: text/html set-cookie: yummy_cookie=choco set-cookie: tasty_cookie=strawberry [page content] then, with every subsequent request to the server, the browser sends back all previously stored cookies to the server using the cookie header.
...And 3 more matches
Digital audio concepts - Web media technologies
by chaining all the samples together, you can approxima
tely represent the original wave, as seen in the diagram below.
... the most common sample rates are: 8000 hz the international g.711 standard for audio used in
telephony uses a sample rate of 8000 hz (8 khz).
...the nyquist-shannon sampling theorem dictates that to reproduce a sound accura
tely, it must be sampled at twice the rate of the sound's frequency.
...And 3 more matches
Performance fundamentals - Web Performance
ultima
tely, user-perceived performance is the only performance that matters.
...a
television probably looks choppy and unrealistic to a hummingbird, for example.
...in
telligently allocating memory to user state is an important concern that we go over in more detail below.
...And 3 more matches
cfx - Archive of obsolete content
updateurl and upda
telink if you choose to host the xpi yourself you should enable the host application to find new versions of your add-on.
...at the updateurl you host a file in the update rdf format: among other things, this includes another url called upda
telink which points to the updated xpi itself.
... the --update-link option builds an update rdf alongside the xpi, and embeds the supplied url in the update rdf as the value of upda
telink.
...And 2 more matches
Canvas code snippets - Archive of obsolete content
function canvas2dcontext(canvas) { if (typeof canvas === 'string') { canvas = document.ge
telementbyid(canvas); } if (!(this instanceof canvas2dcontext)) { return new canvas2dcontext(canvas); } this.context = this.ctx = canvas.getcontext('2d'); if (!canvas2dcontext.prototype.arc) { canvas2dcontext.setup.call(this, this.ctx); } } canvas2dcontext.setup = function() { var methods = ['arc', 'arcto', 'beginpath', 'beziercurveto', 'clearrect', 'clip', 'closepath', 'dra...
... 'quadraticcurveto', 'rect', 'restore', 'rotate', 'save', 'scale', 'settransform', 'stroke', 'strokerect', 'stroketext', 'transform', 'translate']; var gettermethods = ['createpattern', 'drawfocusring', 'ispointinpath', 'measuretext', // drawfocusring not currently supported // the following might instead be wrapped to be able to chain their child objects 'createimagedata', 'crea
telineargradient', 'createradialgradient', 'getimagedata', 'putimagedata' ]; var props = ['canvas', 'fillstyle', 'font', 'globalalpha', 'globalcompositeoperation', 'linecap', 'linejoin', 'linewidth', 'miterlimit', 'shadowoffsetx', 'shadowoffsety', 'shadowblur', 'shadowcolor', 'strokestyle', 'textalign', 'textbaseline']; for (let m of methods) { let method = m; canvas2dcont...
...hods) { let method = m; canvas2dcontext.prototype[method] = function() { return this.ctx[method].apply(this.ctx, arguments); }; } for (let p of props) { let prop = p; canvas2dcontext.prototype[prop] = function(value) { if (value === undefined) return this.ctx[prop]; this.ctx[prop] = value; return this; }; } }; var canvas = document.ge
telementbyid('canvas'); // use context to get access to underlying context var ctx = canvas2dcontext(canvas) .strokestyle('rgb(30, 110, 210)') .transform(10, 3, 4, 5, 1, 0) .strokerect(2, 10, 15, 20) .context; // use property name as a function (but without arguments) to get the value var strokestyle = canvas2dcontext(canvas) .strokestyle('rgb(50, 110, 210)') .strokestyle(); code usab...
...And 2 more matches
Miscellaneous - Archive of obsolete content
efox" for firefox services.appinfo.version; // returns "2.0.0.1" for firefox version 2.0.0.1 retrieving the version of an extension as specified in the extension's install.rdf components.utils.import("resource://gre/modules/addonmanager.jsm"); addonmanager.getaddonbyid("extension-guid@example.org", function(addon) { // this is an asynchronous callback function that might not be called immedia
tely alert("my extension's version is " + addon.version); }); restarting firefox/thunderbird/seamonkey_2.0 for firefox 3 see onwizardfinish around here: http://mxr.mozilla.org/seamonkey/sou...pdates.js#1639 for firefox 2 see around here: http://mxr.mozilla.org/mozilla1.8/so...pdates.js#1631 bug 338039 tracks improving this situation by providing a simple method to restart the application.
...</div> <script type="text/javascript"> var elm = document.ge
telementbyid("scrollarea"); elm.addeventlistener("dommousescroll", function scroll(event){ //event.detail is positive for a downward scroll, negative for an upward scroll alert("scrolling " + event.detail + " lines"); }, false); </script> if you do not receive a dommousescroll event while holding any of the modifier keys (ctrl,shift,alt,meta) you should check the mousewheel.withcontrolk...
... var focusedcontrol; window.addeventlistener("load", function(e) { onwindowload(e); }, false); function onwindowload() { gbrowser.addeventlistener("load", onpageload, true); } function onpageload() { pagedoc = document.commanddispatcher.focusedwindow.document; var inputlist = pagedoc.ge
telementsbytagname('input'); for (var i=1; i<inputlist.length; i++) { inputlist.item(i).
...And 2 more matches
Interaction between privileged and non-privileged pages - Archive of obsolete content
to trigger the alert() in the listener and pass the data from the web page, write code such as this in the web page: var element = document.createelement("myextensiondataelement"); element.setattribute("attribute1", "foobar"); element.setattribute("attribute2", "hello world"); document.documen
telement.appendchild(element); var evt = document.createevent("events"); evt.initevent("myextensionevent", true, false); element.dispatchevent(evt); this code creates an arbitrary element -- <myextensiondataelement/> -- and inserts it into the web page's dom.
...so to trigger the right event on the right page we have to
tell the extension which page to call.
...ed from web page: " + evt.target.getattribute("attribute1") + "/" + evt.target.getattribute("attribute2")); /* the extension answers the page*/ evt.target.setattribute("attribute3", "the extension"); var doc = evt.target.ownerdocument; var answerevt = doc.createelement("myextensionanswer"); answerevt.setattribute("part1", "answers this."); doc.documen
telement.appendchild(answerevt); var event = doc.createevent("htmlevents"); event.initevent("myanswerevent", true, false); answerevt.dispatchevent(event); } } document.addeventlistener("myextensionevent", function(e) { myextension.mylistener(e); }, false, true); // the last value is a mozilla-specific value to indicate untrusted content is allowed to trigger the event.
...And 2 more matches
Connecting to Remote Content - Archive of obsolete content
in asynchronous mode code execution continues immedia
tely after the send call.
... request.onload = function(aevent) { let responsexml = aevent.target.responsexml; let roo
telement = responsexml.documen
telement; if (roo
telement && "parseerror" != roo
telement.tagname) { let shopelements = roo
telement.ge
telementsbytagname("shop"); let totalelement = roo
telement.ge
telementsbytagname("total")[0]; window.alert(shopelements[1].ge
telementsbytagname("name")[0].firstchild.nodevalue); // => orange window.alert(totalelement.firstchild.nodevalue); ...
... request.onload = function(aevent) { let responsexml = aevent.target.responsexml; let xulnode; // transform the xml document to a xul document xuldocument = xsltprocessor.transformtodocument(responsexml); // append the xul node to a xul element xulnode = document.adoptnode(xuldocument.firstchild); document.ge
telementbyid("foo").appendchild(xulnode); }; we effectively transformed the xml file into xul and integrated it into the ui.
...And 2 more matches
Appendix E: DOM Building and Insertion (HTML & XUL) - Archive of obsolete content
event listeners can be defined on the given nodes by passing functions rather than strings to on* attributes: var href = "http://www.google.com/"; var text = "google"; var nodes = {}; document.documen
telement.appendchild( jsontodom(["xul:hbox", {}, ["div", {}, ["a", { href: href, key: "link", onclick: function (event) { alert(event.target.href); } }, text], ["span", { class: "stuff" }, "stuff"]]], document, nodes)); alert(nodes.link); function addentrytopopup(menupopup, doc, chromewindow) { var ...
...ype: "menu", label: "test button label", tooltiptext: "test button tooltip", removable: true, key: "mytestbutton123" }, [ "menupopup", { onpopupshowing: function(event) { addentrytopopup(this, document, window); } }, null ] ]; var capturednodes = {}; var toolbox = doc.ge
telementbyid("navigator-toolbox"); var palette = toolbox.palette; var domfragment = jsontodom(jsontemplatebtn, document, capturednodes); palette.appendchild(domfragment); alert("capturednodes contains any created nodes that have optionally been captured (for later convenient javascript access) by giving them a 'key' attribute; for example: " + capturednodes.mytestbutton123); another example this ...
... var href = "http://www.google.com/"; var text = "google"; document.ge
telementbyid("target-div").innerhtml = '<div>\ <a href="' + escapehtml(href) + '" target="_top">' + escapehtml(text) + '</a>\ </div>' it needs to be stressed that this method should not be used in new code and is only a temporary measure to shore up legacy code bases.
...And 2 more matches
List of Mozilla-Based Applications - Archive of obsolete content
mium and google chrome web browser uses mozilla nss and npapi libraries chromeless browser with html-based interface classilla mozilla browser for mac os 9 clines a clone of color lines (game) standalone version cloud web operating system cloud browse iphone/ipad/ipod touch browser seems to be firefox running remo
tely on servers that people access through device conkeror keyboard-oriented browser convertigo enterprise mashup server server tool for transactional web scraping and for web clipping cometbird another firefox mod modified version of firefox correo email couac (fr) web-based email and jabber app couchdb docume...
... en
telechy chat bot uses xulrunner epic browser web browser based on chromium uses mozilla nss and npapi libraries emusic download manager music downloader for emusic emusic remote music manager enlis genome personal genome browser esxx javascript application server uses mozilla rhino etna xml wysiw...
... evergreen library automation system evolution email client uses nss exe elearning xhtml editor seems to be using xul for some of their webui facebook open platform facebook open platform the fbml parser used in the platform is based on mozilla code fennec browser for mobiles as mark notes: fennec is not firefox, it’s a comple
tely different application findthatfont!
...And 2 more matches
Commands - Archive of obsolete content
example: toggling command disabled example 2 : source view <command id="cmd_openhelp" oncommand="alert('help');"/> <button label="help" command="cmd_openhelp"/> <button label="more help" command="cmd_openhelp"/> <button label="disable" oncommand="document.ge
telementbyid('cmd_openhelp').setattribute('disabled','true');"/> <button label="enable" oncommand="document.ge
telementbyid('cmd_openhelp').removeattribute('disabled');"/> in this example, both buttons use the same command.
...the example below isn't comple
tely polished.
... really, we should ensure that the selection and focus is adjusted appropria
tely after a deletion.
...And 2 more matches
XUL Structure - Archive of obsolete content
standalone xul applications may include xul code in a similar way, but, of course, the xul for the application will be included as part of the installation, instead of having to be installed separa
tely as an extension.
...the packaging system is flexible enough so that you can include whatever parts you need and allow other parts, such as the text for different languages, to be downloaded separa
tely.
...they are stored separa
tely from xul files to facilitate modifying the skin (theme) of an application.
...And 2 more matches
calICalendarView - Archive of obsolete content
e calicalendar displaycalender; attribute calicalendarviewcontroller controller; void showdate(in calidatetime adate); void setdaterange(in calidatetime astartdate, in calidatetime aenddate); readonly attribute calidatetime startdate; readonly attribute calidatetime enddate; readonly attribute boolean supportsdisjointdates; readonly attribute boolean hasdisjointdates; void setda
telist(in unsigned long acount, [array,size_is(acount)] in calidatetime adates); void getda
telist(out unsigned long acount, [array,size_is(acount),retval] out calidatetime adates); attribute caliitembase selecteditem; attribute calidatetime selectedday; attributes displaycalendar the displaycalendar is an implementation of the calicalendar interface.
...note that this date is typically not immedia
tely useful for querying for the events and tasks shown in the calicalendarview.
... supportsdisjointdates consumers of calicalendarview should check this attribute to determine whether or not the implementation allows for calls to setda
telist.
...And 2 more matches
Extentsions FAQ - Archive of obsolete content
"); var replaceme = document.ge
telementbyid("replaceme"); replaceme.parentnode.replacechild(newnode, replaceme); is it possible to place an image in the window that can be moved to anywhere in the window, and always remain on top of everything else?(similiar to using position:absolute and-index:100000 in html) you can almost do this with a stack: <window ...> <stack flex="1"> <image top="40" left="80"/> <vb...
...the appearance with a firefox tab isn't quite the same as having a comple
tely separate explorer window.
... //setting the state document.ge
telementbyid("toolbar-button").setattribute("toolbar-button", "on"); //or document.ge
telementbyid("toolbar-button").setattribute("toolbar-button","off"); //css #myexten-toolbar-button[myexten-toolbar-button="on"] { list-style-image: url("chrome://myexten/skin/toolbar-button.png"); -moz-image-region: rect(0px 24px 24px 0px);} #myexten-toolbar-button[myexten-toolbar-button="off"] { list-sty...
...And 2 more matches
Building a Theme - Archive of obsolete content
the browser ui has absolu
tely no styling on its own - if you try to start up with an empty theme, firefox will be unusable, as the button elements will be drawn as plain text.
... chrome uris next, we have to
tell firefox where to find the theme files for your theme.
... chrome uris consist of several components: firstly, the uri scheme (chrome) which
tells firefox's networking library that this is a chrome uri.
...And 2 more matches
Developing cross-browser and cross-platform pages - Archive of obsolete content
it requires from the web author to have knowledge of the capabilities of all current browsers that may visit the page and then to code appropria
tely for these.
...moreover, there are many cases where even the accura
tely-identified browser does not perform as it is reputed/expected to.
... function hideelement(id_attribute_value) { if (document.ge
telementbyid && document.ge
telementbyid(id_attribute_value) && document.ge
telementbyid(id_attribute_value).style ) { document.ge
telementbyid(id_attribute_value).style.visibility = "hidden"; }; } // example: // <button type="button" onclick="hideelement('d1');">hide div</button> // <div id="d1">some text</div> these repeated calls to document.ge
telementbyid are not the most effic...
...And 2 more matches
Reference - Archive of obsolete content
well if you combine the two, you can have inherited private variables: function myclass(){ var property = 5; this.
tellme = function(){ return property; } } function myotherclass(){ myclass.apply( this ); } var o = new myotherclass; alert( o.
tellme() ); //alerts 5 as you'd expect — the preceding comment was added by psygnisfive (talk – contribs) on 22:23, 4 december 2006 terminology we need a terminology appendix.
... unfortuna
tely there is not an [easy] method to download content/packages of content off of devmo for 'local' browsing/viewing/printing, yet.
...while also holding in account the previous example where it was avalable in both instances when prototyping object it should be : function->object->instance or (function=object)->instance and ofcourse function == object return false ;) and the following statements also
tells me that function == object although math is only an instance of object...
...And 2 more matches
Efficient animation for web games - Game development
to take a concrete example, if you start a css transition to move something from off-screen so that it is fully visible on-screen, the browser knows that the related content will end up comple
tely visible to the user and can then pre-render that content.
... use requestanimationframe when you are animating <canvas> content, or when your dom animations absolu
tely must synchronise with canvas content animations, do make sure to use window.requestanimationframe, and not older methods such as window.settimeout.
...requestanimationframe includes a domhighrestimestamp in its callback function prototype, which you defini
tely should use (as opposed to using the date object), as this will be the time the frame began rendering, and ought to make your animations look more fluid.
...And 2 more matches
How to structure a web form - Learn web development
the above variants increase in effectiveness as you go through them: in the first example, the label is not read out at all with the input — you just get "edit text blank", plus the actual labels are read out separa
tely.
... in the second example, things are a bit clearer — the label read out along with the input is "name star name edit text required", and the labels are still read out separa
tely.
...don't test the example with 2 or 3 of the versions uncommented — screenreaders will defini
tely get confused if you have multiple labels and multiple inputs with the same id!
...And 2 more matches
Sending forms through JavaScript - Learn web development
fortuna
tely, the xmlhttprequest specification provides a newer, simpler way to handle form data requests with the formdata object.
... const form = document.ge
telementbyid( "myform" ); // ...and take over its submit event.
...unfortuna
tely, some legacy browsers can't access binary data or require complicated workarounds.
...And 2 more matches
Your first form - Learn web development
forms allow users to enter data, which is generally sent to a web server for processing and storage (see sending form data later in the module), or used on the client-side to immedia
tely update the interface in some way (for example, add another item to a list, or show or hide a ui feature).
...keep it simple and stay focused: ask only for the data you absolu
tely need.
...this turns a basic text field into a kind of "in
telligent" field that will perform some validation checks on the data typed by the user.
...And 2 more matches
Advanced text formatting - Learn web development
brown color.</textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); const output = document.queryselector('.output'); const code = textarea.value; const userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; ...
...f markup contains a quotation from the mdn <q> page: <p>the quote element — <code><q></code> — is <q cite="/docs/web/html/element/q">intended for short quotations that don't require paragraph breaks.</q></p> browser default styling will render this as normal text put in quotes to indicate a quotation, like so: citations the content of the cite attribute sounds useful, but unfortuna
tely browsers, screenreaders, etc.
...nking.)</p> </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); const output = document.queryselector('.output'); const code = textarea.value; const userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; ...
...And 2 more matches
Getting started with HTML - Learn web development
it is a markup language that
tells web browsers how to structure the web pages you visit.
...class="controls"> <input id="reset" type="button" value="reset" /> <input id="solution" type="button" value="show solution" /> </div> html { font-family: 'open sans light',helvetica,arial,sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var solution = document.ge
telementbyid('solution'); var output = document.queryselector('.output'); var code = textarea.value; var userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutione...
...te.</p> </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var solution = document.ge
telementbyid('solution'); var output = document.queryselector('.output'); var code = textarea.value; var userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutione...
...And 2 more matches
Images in HTML - Learn web development
fortuna
tely, it wasn't too long before the ability to embed images (and other more interesting types of content) inside web pages was added.
...if the image is described adequa
tely by the main text body, you can just use alt="".
...: 95%"> <img> </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var solution = document.ge
telementbyid('solution'); var output = document.queryselector('.output'); var code = textarea.value; var userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutione...
...And 2 more matches
Introducing asynchronous JavaScript - Learn web development
when you fetch an image from a server, you can't return the result immedia
tely.
... when we pass a callback function as an argument to another function, we are only passing the function's reference as an argument, i.e, the callback function is not executed immedia
tely.
...however, it doesn't wait for anything — it runs immedia
tely.
...And 2 more matches
Test your skills: Conditionals - Learn web development
if not, it should assign a generic string to response that
tells the user we don't know what season it is.
... you need to create an if...else structure that checks whether the machine is switched on and puts a message into the response variable if it isn't,
telling the user to switch the machine on.
... we'd like you to create an if...else structure that checks whether the machine is switched on and puts a message into the machineresult variable
telling the user whether it is on or off.
...And 2 more matches
Manipulating documents - Learn web development
there are older methods available for grabbing element references, such as: document.ge
telementbyid(), which selects an element with a given id attribute value, e.g.
...const elementref = document.ge
telementbyid('myid').
... document.ge
telementsbytagname(), which returns an array-like object containing all the elements on the page of a given type, for example <p>s, <a>s, etc.
...And 2 more matches
Video and Audio APIs - Learn web development
if you don't specify this, you get no playback controls: this is not as immedia
tely useful for video playback, but it does have advantages.
...you'll see a number of features; the html is dominated by the video player and its controls: <div class="player"> <video controls> <source src="video/sin
tel-short.mp4" type="video/mp4"> <source src="video/sin
tel-short.webm" type="video/webm"> <!-- fallback content here --> </video> <div class="controls"> <button class="play" data-icon="p" aria-label="play pause toggle"></button> <button class="stop" data-icon="s" aria-label="stop"></button> <div class="timer"> <div></div> <span aria-label="timer">00:00</span> <...
... the inner <div> is absolu
tely positioned to sit directly on top of the outer <div>.
...And 2 more matches
Client-Server Overview - Learn web development
the header contains information like the following: the first line includes the response code 200 ok, which
tells us that the request succeeded.
... the head also
tells us how big it is (content-length: 41823).
...deny allow: get x-cache-info: caching content-length: 41823 <!doctype html> <html lang="en-us" dir="ltr" class="redesign no-js" data-ffo-opensanslight=false data-ffo-opensans=false > <head prefix="og: http://ogp.me/ns#"> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <script>(function(d) { d.classname = d.classname.replace(/\bno-js/, ''); })(document.documen
telement);</script> ...
...And 2 more matches
Gecko info for Windows accessibility vendors
ajax: asynchronous javascript and xml ajax is a method of building interactive web applications that process user requests, user actions immedia
tely in real time, unlike an http request, during which users must wait for a whole page to reload or for a new page to load.
... additional dom support there are a number of things available in the parsed html or xml of a document that msaa will not
tell you.
...unfortuna
tely, at this time the argument usealternateview is ignored.
...And 2 more matches
Application cache implementation overview
when the url in the manifest attribute of the html tag is identical to the manifest url the channel's nsiapplicationcache object belongs to and, the channel's loadedfromapplicationcache flag is set, the document is associated with that nsiapplicationcache object and an update attempt for the manifest is scheduled after the document comple
tely loads.
... marking entries as foreign when nscontentsink::processofflinemanifest() discovers that the url in the manifest attribute of the html tag is different from the manifest url the channel's nsiapplicationcache object belongs to, the entry the document has been loaded from is marked “foreign” and the page load is comple
tely restarted.
... the load starts again from the top with a comple
tely new channel.
...And 2 more matches
HTTP Cache
the cache api is comple
tely thread-safe and non-blocking.
... it will soon be comple
tely obsoleted and removed (bug 913828).
... two storage objects created with in any way different nsiloadcontextinfo arguments are strictly and comple
tely distinct and cache entries in them do not overlap even when having the same uris.
...And 2 more matches
IME handling guide
when composition comple
tely ends, it's unregistered from the list (and released automatically).
...unfortuna
tely, it's not allowed to use syncronous communication from chrome process to a remote process.
... note that even if there are pending notifications, they are canceled when notify_ime_of_focus is sent since querying content with following notifications immedia
tely after getting focus does not make sense.
...And 2 more matches
DeferredTask.jsm
void start(); flush obsolete since gecko 28 perform any postponed task immedia
tely.
... if the task is running and the timer is armed, then one last execution from start to finish will happen again, immedia
tely after the current execution terminates; then the returned promise will be resolved.
... if the task is not running and the timer is armed, then the task is started immedia
tely, and the returned promise resolves when the new execution terminates.
...And 2 more matches
Following the Android Toasts Tutorial from a JNI Perspective
the arguments are within the parenthesis, and the return type is immedia
tely following.
...the documentation
tells us.
...fields do not accept arguments, so the "method format" is not used, we simply
tell the sig the type of the field, which we find out from the android documentation website.
...And 2 more matches
powermetrics
the following command encompasses the most useful ones: sudo powermetrics --samplers tasks --show-process-coalition --show-process-gpu -n 1 -i 5000 --samplers tasks
tells it to just do per-process measurements.
... --show-process-coalition
tells it to group coalitions of related processes, e.g.
... --show-process-gpu
tells it to show per-process gpu measurements.
...And 2 more matches
JS::CompileOptions
callers should set this flag for cross-origin scripts, and it will be propagated appropria
tely to child scripts and passed back in jserrorreports.
... owningcompileoptions &se
telement(jsobject *e) owningcompileoptions &se
telementattributename(jsstring *p) owningcompileoptions &setintroductionscript(jsscript *s) owningcompileoptions &setmutederrors(bool mute) owningcompileoptions &setversion(jsversion v) owningcompileoptions &setutf8(bool u) owningcompileoptions &setcolumn(unsigned c) owningcompileoptions &setc...
... compileoptions &setline(unsigned l) compileoptions &setfileandline(const char *f, unsigned l) compileoptions &setsourcemapurl(const char16_t *s) compileoptions &se
telement(jsobject *e) compileoptions &se
telementattributename(jsstring *p) compileoptions &setintroductionscript(jsscript *s) compileoptions &setmutederrors(bool mute) compileoptions &setversion(jsversion v) compileoptions &setutf8(bool u) compileoptions &setcolumn(unsigned c) compileoptions &setcompileandgo(bool cng) compileopti...
...And 2 more matches
Using the Places livemark service
initiating the livemark service before using the livemark service, you need to obtain an instance: var livemarkservice = components.classes["@mozilla.org/browser/livemark-service;2"] .getservice(components.interfaces.nsilivemarkservice); creating a new livemark the nsilivemarkservice.crea
telivemark() method creates a new livemark.
... var newlvmkid = livemarkservice.crea
telivemark(parentfolderid, "livemark name", uri("http://example.com/"), uri("http://example.com/rss.xml"), -1); the first parameter is the id of the folder in which to create the livemark.
...when creating livemarks during startup, you should use the nsilivemarkservice.crea
telivemarkfolderonly() to avoid http traffic.
...And 2 more matches
XPCOM array guide
// get the array nscomptr<nsiarray> array; foo->ge
telements(getter_addrefs(array)); // make an enumerator nscomptr<nsisimpleenumerator> enumerator; array->enumerate(getter_addrefs(enumerator)); // now enumerate the elements ...
... void processvisibleitems() { // temporary stack-based nscomarray nscomarray<nsifoo> fooitems; getcomple
telist(fooitems); // now filter out non visible objects // doing this backwards pruint32 i = fooitems.count(); while (i > 0) { --i; prbool isvisible; fooitems[i]->getisvisible(&isvisible); if (!isvisible) { fooitems.removeobjectat(i); } } // now deal with the processed list processlist(fooitems); // fooitems will release all its members // when it goes o...
... for example: // melements is an nscomarray<nsielement> nsfoo::ge
telements(nsisimpleenumerator** aresult) { return ns_newarrayenumerator(aresult, melements); } deleting objects requires gecko 6.0(firefox 6.0 / thunderbird 6.0 / seamonkey 2.3) gecko 6.0 (firefox 6.0 / thunderbird 6.0 / seamonkey 2.3) introduces the removeobjectsat() method to nscomarray<t>.
...And 2 more matches
imgIContainer
obsolete since gecko 2.0 void appendpalettedframe(in print32 ax, in print32 ay, in print32 awidth, in print32 aheight, in gfximageformat aformat, in pruint8 apalettedepth, [array, size_is(imagelength)] out pruint8 imagedata, out unsigned long imagelength, [array, size_is(palet
telength)] out pruint32 palettedata, out unsigned long palet
telength); native code only!
... gfxiimageframe getframeat(in unsigned long index); obsolete since gecko 1.9.2 void getframecolormap(in unsigned long framenumber, [array, size_is(palet
telength)] out pruint32 palettedata, out unsigned long palet
telength); obsolete since gecko 2.0 unsigned long getframeimagedatalength(in unsigned long framenumber); obsolete since gecko 2.0 imagecontainer getimagecontainer(); native code only!
...void appendpalettedframe( in print32 ax, in print32 ay, in print32 awidth, in print32 aheight, in gfximageformat aformat, in pruint8 apalettedepth, [array, size_is(imagelength)] out pruint8 imagedata, out unsigned long imagelength, [array, size_is(palet
telength)] out pruint32 palettedata, out unsigned long palet
telength ); parameters ax missing description ay missing description awidth missing description aheight missing description aformat missing description apalettedepth missing description imagedata missing description imagelength missing description palettedata missing...
...And 2 more matches
nsICollection
inherits from: nsiserializable last changed in gecko 1.7 method overview void appendelement(in nsisupports item); void clear(); pruint32 count(); nsienumerator enumerate(); nsisupports ge
telementat(in pruint32 index); void queryelementat(in pruint32 index, in nsiidref uuid, [iid_is(uuid),retval] out nsqiresult result); void removeelement(in nsisupports item); void se
telementat(in pruint32 index, in nsisupports item); methods appendelement() appends a new item to the collection.
...ge
telementat() returns the element at the specified index into the collection.
... nsisupports ge
telementat( in pruint32 index ); parameters index the index position of the item to be returned.
...And 2 more matches
nsIDOMElement
inherits from: nsidomnode last changed in gecko 1.7 method overview domstring getattribute(in domstring name); nsidomattr getattributenode(in domstring name); nsidomattr getattributenodens(in domstring namespaceuri, in domstring localname); domstring getattributens(in domstring namespaceuri, in domstring localname); nsidomnodelist ge
telementsbytagname(in domstring name); nsidomnodelist ge
telementsbytagnamens(in domstring namespaceuri, in domstring localname); boolean hasattribute(in domstring name); boolean hasattributens(in domstring namespaceuri, in domstring localname); void removeattribute(in domstring name) nsidomattr removeattributenode(in nsidomattr oldattr) void removeattributens(in domstring namespaceuri, in...
...ge
telementsbytagname() get all descendants of a tag name.
... nsidomnodelist ge
telementsbytagname( in domstring name ); parameters name tag name return value a nsidomnodelist containg all the descendants of this tag name.
...And 2 more matches
nsIDOMXULElement
66 introduced gecko 1.0 inherits from: nsidomelement last changed in gecko 1.9 (firefox 3) method overview void blur(); void click(); void docommand(); void focus(); nsidomnodelist ge
telementsbyattribute(in domstring name, in domstring value); nsidomnodelist ge
telementsbyattributens(in domstring namespaceuri, in domstring name, in domstring value); attributes attribute type description align domstring gets/sets the value of the element's align attribute.
...ge
telementsbyattribute() searches the dom subtree for elements with the given attribute that are not in a namespace.
... nsidomnodelist ge
telementsbyattribute( in domstring name, in domstring value ); parameters name the name of the attribute to search for.
...And 2 more matches
nsIFocusManager
idomelement getfocusedelementforwindow(in nsidomwindow awindow, in prbool adeep, out nsidomwindow afocusedwindow); pruint32 getlastfocusmethod(in nsidomwindow window); void movecarettofocus(in nsidomwindow awindow); void elementisfocusable(in nsidomelement aelement, in unsigned long aflags); nsidomelement movefocus(in nsidomwindow awindow, in nsidomelement astar
telement, in unsigned long atype, in unsigned long aflags); void setfocus(in nsidomelement aelement, in unsigned long aflags); void windowhidden(in nsidomwindow awindow); native code only!
...if astar
telement is specified, then movement is done relative to astar
telement.
... if astar
telement is null, then movement is done relative to the currently focused element.
...And 2 more matches
nsIMutableArray
note also that null elements can be created as a side effect of inser
telementat().
... conversely, if inser
telementat() is never used, and null elements are never explicitly added to the array, then it is guaranteed that nsiarray.queryelementat() will never return a null value.
...method overview void appendelement(in nsisupports element, in boolean weak); void clear(); void inser
telementat(in nsisupports element, in unsigned long index, in boolean weak); void removeelementat(in unsigned long index); void replaceelementat(in nsisupports element, in unsigned long index, in boolean weak); methods appendelement() append an element at the end of the array.
...And 2 more matches
nsIZipWriter
if false, the operation is performed immedia
tely.
...if false, the operation is performed immedia
tely.
...if false, the operation is performed immedia
tely.
...And 2 more matches
CSS Grid Inspector: Examine grid layouts - Firefox Developer Tools
extend lines infini
tely: by default, grid lines/tracks are only shown inside the element with display: grid set on it; when toggling this option on, the grid lines extend to the edge of the viewport along each axis.
... a target icon that when clicked immedia
tely selects the html element that this grid entry relates to, inside the html pane.
...this is useful for selecting different colors so you can easily
tell your grids apart.
...And 2 more matches
Call Tree - Firefox Developer Tools
the call tree
tells you which javascript functions the browser spent the most time in.
... by analyzing its results, you can find bottlenecks in your code - places where the browser is spending a disproportiona
tely large amount of time.
... this screenshot
tells us something we probably already knew: bubble sort is a very inefficient algorithm.
...And 2 more matches
Basic usage of canvas - Web APIs
this can look something like this: <canvas id="stockgraph" width="150" height="150"> current stock price: $3.15 + 0.15 </canvas> <canvas id="clock" width="150" height="150"> <img src="images/clock.png" width="150" height="150" alt=""/> </canvas>
telling the user to use a different browser that supports canvas does not help users who can't read the canvas at all, for example.
... var canvas = document.ge
telementbyid('tutorial'); var ctx = canvas.getcontext('2d'); the first line in the script retrieves the node in the dom representing the <canvas> element by calling the document.ge
telementbyid() method.
...our code snippet from above becomes something like this: var canvas = document.ge
telementbyid('tutorial'); if (canvas.getcontext) { var ctx = canvas.getcontext('2d'); // drawing code here } else { // canvas-unsupported code here } a skeleton template here is a minimalistic template, which we'll be using as a starting point for later examples.
...And 2 more matches
Transformations - Web APIs
function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); ctx.fillrect(0, 0, 150, 150); // draw a rectangle with default settings ctx.save(); // save the default state ctx.fillstyle = '#09f'; // make changes to the settings ctx.fillrect(15, 15, 120, 120); // draw a rectangle with new settings ctx.save(); // save the current state ctx.fillstyle = '#fff'; // ...
... function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); for (var i = 0; i < 3; i++) { for (var j = 0; j < 3; j++) { ctx.save(); ctx.fillstyle = 'rgb(' + (51 * i) + ', ' + (255 - 51 * i) + ', 255)'; ctx.translate(10 + j * 50, 10 + i * 50); ctx.fillrect(0, 0, 25, 25); ctx.restore(); } } } <canvas id="canvas" width="150" height="150"></canvas> draw(); screenshotlive samp...
... function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); // left rectangles, rotate from canvas origin ctx.save(); // blue rect ctx.fillstyle = '#0095dd'; ctx.fillrect(30, 30, 100, 100); ctx.rotate((math.pi / 180) * 25); // grey rect ctx.fillstyle = '#4d4e53'; ctx.fillrect(30, 30, 100, 100); ctx.restore(); // right rectangles, rotate from rectangle center // draw blue rect ctx.fillstyle =...
...And 2 more matches
DocumentFragment - Web APIs
parentnode.firs
telementchild read only returns the element that is the first child of the documentfragment object, or null if there is none.
... parentnode.las
telementchild read only returns the element that is the last child of the documentfragment object, or null if there is none.
... documentfragment.ge
telementbyid() returns the first element node within the documentfragment, in document order, that matches the specified id.
...And 2 more matches
How whitespace is handled by HTML, CSS, and in the DOM - Web APIs
inside this context, whitespace character processing can be summarized as follows: first, all spaces and tabs immedia
tely before and after a line break are ignored so, if we take our example markup from before and apply this first rule, we get: <h1>◦◦◦hello⏎ <span>◦world!</span>⇥◦◦</h1> next, all tab characters are handled as space characters, so the example becomes: <h1>◦◦◦hello⏎ <span>◦world!</span>◦◦◦</h1> next, line breaks are converted to spaces: <h1>◦◦�...
...��hello◦<span>◦world!</span>◦◦◦</h1> after that, any space immedia
tely following another space (even across two separate inline elements) is ignored, so we end up with: <h1>◦hello◦<span>world!</span>◦</h1> and finally, sequences of spaces at the beginning and end of a line are removed, so we finally get this: <h1>hello◦<span>world!</span></h1> this is why people visiting the web page will simply see the phrase "hello world!" nicely written at the top of the page, rather than a weirdly indented "hello" followed but an even more weirdly indented "world!" on the line below that.
...this handles everything for you, and is defini
tely the preferred solution: ul { list-style-type: none; margin: 0; padding: 0; display: flex; } if you need to rely on inline-block, you could set the font-size of the list to 0.
...And 2 more matches
Element.closest() - Web APIs
syntax var closes
telement = targe
telement.closest(selectors); parameters selectors is a domstring containing a selector list.
... ex: p:hover, .toto + q return value closes
telement is the element which is the closest ancestor of the selected element.
... example html <article> <div id="div-01">here is div-01 <div id="div-02">here is div-02 <div id="div-03">here is div-03</div> </div> </div> </article> javascript var el = document.ge
telementbyid('div-03'); var r1 = el.closest("#div-02"); // returns the element with the id=div-02 var r2 = el.closest("div div"); // returns the closest ancestor which is a div in div, here it is the div-03 itself var r3 = el.closest("article > div"); // returns the closest ancestor which is a div and has a parent article, here it is the div-01 var r4 = el.closest(":not(div)"); // returns the closest ancestor which is not a div, here it is the outmost article polyfill for browse...
...And 2 more matches
HTMLTableElement - Web APIs
if a correct object is given, it is inserted in the tree immedia
tely before the first element that is neither a <caption>, nor a <colgroup>, or as the last child if there is no such element, and the first <thead> that is a child of this element is removed from the tree, if any.
...if a correct object is given, it is inserted in the tree immedia
tely before the first element that is neither a <caption>, a <colgroup>, nor a <thead>, or as the last child if there is no such element, and the first <tfoot> that is a child of this element is removed from the tree, if any.
...if none is found, a new one is created and inserted in the tree immedia
tely before the first element that is neither a <caption>, nor a <colgroup>, or as the last child if there is no such element.
...And 2 more matches
RTCPeerConnection - Web APIs
the event is sent immedia
tely after the call setremotedescription() and doesn't wait for the result of the sdp negotiation.onconnectionstatechangethe rtcpeerconnection.onconnectionstatechange property specifies an eventhandler which is called to handle the connectionstatechange event when it occurs on an instance of rtcpeerconnection.
...because this method has been deprecated, you should instead use removetrack() if your target browser versions have implemented it.removetrack()the rtcpeerconnection.removetrack() method
tells the local end of the connection to stop sending media from the specified track, without actually removing the corresponding rtcrtpsender from the list of senders as reported by rtcpeerconnection.getsenders().restartice()the webrtc api's rtcpeerconnection interface offers the restartice() method to allow a web application to easily request that ice candidate gathering be redone on both ends of t...
...otherwise, both the rtp and rtcp candidates are returned, separa
tely.
...And 2 more matches
A simple RTCDataChannel sample - Web APIs
function startup() { connectbutton = document.ge
telementbyid('connectbutton'); disconnectbutton = document.ge
telementbyid('disconnectbutton'); sendbutton = document.ge
telementbyid('sendbutton'); messageinputbox = document.ge
telementbyid('message'); receivebox = document.ge
telementbyid('receivebox'); // set event listeners for user interface widgets connectbutton.addeventlistener('click', connectpeers, false); disconnectbutton.addev...
... set up the ice candidates the next step is to set up each connection with ice candidate listeners; these will be called when there's a new ice candidate to
tell the other side about.
... the next step is to connect the local peer to the remote by
telling the remote peer about it.
...And 2 more matches
WebRTC API - Web APIs
the set of standards that comprise webrtc makes it possible to share data and perform
teleconferencing peer-to-peer, without requiring that the user installs plug-ins or any other third-party software.
... webrtc concepts and usage webrtc serves multiple purposes; together with the media capture and streams api, they provide powerful multimedia capabilities to the web, including support for audio and video conferencing, file exchange, screen sharing, identity management, and interfacing with legacy
telephone systems including support for sending dtmf (touch-tone dialing) signals.
...its underlying data transport is comple
tely closed at this point.
...And 2 more matches
Alerts - Accessibility
below is example javascript code which could be inserted above the closing “head” tag: <script type="application/javascript"> function removeoldalert() { var oldalert = document.ge
telementbyid("alert"); if (oldalert){ document.body.removechild(oldalert); } } function addalert(amsg) { removeoldalert(); var newalert = document.createelement("div"); newalert.setattribute("role", "alert"); newalert.setattribute("id", "alert"); var msg = document.createtextnode(amsg); newalert.appendchild(msg); document.body.appendchild(newalert); } function c...
...heckvalidity(aid, asearchterm, amsg) { var elem = document.ge
telementbyid(aid); var invalid = (elem.value.indexof(asearchterm) < 0); if (invalid) { elem.setattribute("aria-invalid", "true"); addalert(amsg); } else { elem.setattribute("aria-invalid", "false"); removeoldalert(); } } </script> the checkvalidity function the primary method in javascript used for form validation is the checkvalidity function.
...the alert we just created does not have any buttons to press, it just
tells us what’s wrong.
...And 2 more matches
Cognitive accessibility - Accessibility
cognitive impairment refers to a broad range of disabilities, from people with in
tellectual disabilities who may have the most-limited capabilities, to age-related issues with thinking and remembering.
... overview cognitive and in
tellectual disabilities cover a large spectrum, and may be momentary, temporary, or permanent conditions.
...when a timeout is used,
tell people exactly how much time will cause the session to time out and result in lost data.
...And 2 more matches
Using CSS animations - CSS: Cascading Style Sheets
animation-iteration-count configures the number of times the animation should repeat; you can specify infinite to repeat the animation indefini
tely.
...ein; } @keyframes slidein { from { margin-left: 100%; width: 300%; } 75% { font-size: 300%; margin-left: 25%; width: 150%; } to { margin-left: 0%; width: 100%; } } <p>the caterpillar and alice looked at each other for some time in silence: at last the caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy voice.</p> this
tells the browser that 75% of the way through the animation sequence, the header should have its left margin at 25% and the width should be 150%.
...in this case, let’s use infinite to have the animation repeat indefini
tely: p { animation-duration: 3s; animation-name: slidein; animation-iteration-count: infinite; } adding it to the existing code: @keyframes slidein { from { margin-left: 100%; width: 300%; } to { margin-left: 0%; width: 100%; } } <p>the caterpillar and alice looked at each other for some time in silence: at last the caterpillar took the hookah out of its mouth, and addressed her in a languid, sleepy voice.</p...
...And 2 more matches
Border-radius generator - CSS: Cascading Style Sheets
n init() { var elem = document.queryselectorall('.ui-checkbox'); var size = elem.length; for (var i = 0; i < size; i++) new checkbox(elem[i]); } return { init : init, setvalue : setvalue, subscribe : subscribe, unsubscribe : unsubscribe } })(); window.addeventlistener("load", function() { borderradius.init(); }); var borderradius = (function borderradius() { function ge
telembyid(id) { return document.ge
telementbyid(id); } /** * shadow dragging */ var previewmousetracking = (function drag() { var active = false; var lastx = 0; var lasty = 0; var subscribers = []; var init = function init(id) { var elem = ge
telembyid(id); elem.addeventlistener('mousedown', dragstart, false); document.addeventlistener('mouseup', dragend, false); } va...
...node(this.topic); this.setunitx(this.unitx); this.setunity(this.unity); this.setunitr(this.unitr); this.updatewidth(); this.updateheight(); this.updateradius(); if (x === 'left') this.resizex = 1; if (x === 'right') this.resizex = -1; if (y === 'top') this.resizey = 1; if (y === 'bottom') this.resizey = -1; radius.classname = 'radius'; var unit_selector = document.ge
telementbyid("unit-selection"); var unitw = new unitselector(this.topic + '-w'); var unith = new unitselector(this.topic + '-h'); var unitr = new unitselector(this.topic); unit_selector.appendchild(unitw.container); unit_selector.appendchild(unith.container); unit_selector.appendchild(unitr.container); node.appendchild(radius); subject.appendchild(handle); unitw.select.addeventlis...
...is.maxh; this.updateheight(); } if (deltax || deltay) this.updateborderradius(); } /** * tool manager */ var tool = (function tool() { var preview; var preview_ui; var radius_containers = []; var border_width = 3; var borders1 = [null, null, null, null]; var borders2 = [0, 0, 0, 0]; var updateuiwidth = function updateuiwidth(value) { var pwidth = subject.paren
telement.clientwidth; var left = (pwidth - value) / 2; subject.style.width = value + "px"; for (var i = 0; i < 4; i++) radius_containers[i].updateunits(0); } var updateuiheight = function updateuiheight(value) { var pheight = subject.paren
telement.clientheight; var top = (pheight - value) / 2; subject.style.height = value + "px"; subject.style.top = top - border_width +...
...And 2 more matches
Variable fonts guide - CSS: Cascading Style Sheets
the advantage in choosing the variable font is that you have access to the entire range of weights, widths, and styles available, rather than being constrained to only the few that you previously would have loaded separa
tely.
...the reason for this is that most typefaces have very specific designs for bolder weights and italics that often include comple
tely different characters (lower-case 'a' and 'g' are often quite different in italics, for example).
... in order to most accura
tely reflect the typeface design and avoid differences between browsers and how they may or may not synthesize the different styles, it's more accurate to load the specific font files where needed when using a non-variable font.
...And 2 more matches
Getting Started - Developer guides
at this stage, you need to
tell the xmlhttp request object which javascript function will handle the response, by setting the onreadystatechange property of the object and naming it after the function to call when the request changes state, like this: httprequest.onreadystatechange = nameofthefunction; note that there are no parentheses or parameters after the function name, because you're assigning a reference to the functi...
... <button id="ajaxbutton" type="button">make a request</button> <script> (function() { var httprequest; document.ge
telementbyid("ajaxbutton").addeventlistener('click', makerequest); function makerequest() { httprequest = new xmlhttprequest(); if (!httprequest) { alert('giving up :( cannot create an xmlhttp instance'); return false; } httprequest.onreadystatechange = alertcontents; httprequest.open('get', 'test.html'); httprequest.send(); } function alertcontents() { ...
... then in alertcontents(), we need to replace the line alert(httprequest.responsetext); with: var xmldoc = httprequest.responsexml; var root_node = xmldoc.ge
telementsbytagname('root').item(0); alert(root_node.firstchild.data); this code takes the xmldocument object given by responsexml and uses dom methods to access some of the data contained in the xml document.
...And 2 more matches
Audio and video manipulation - Developer guides
var processor = { timercallback: function() { if (this.video.paused || this.video.ended) { return; } this.computeframe(); var self = this; settimeout(function () { self.timercallback(); }, 16); // roughly 60 frames per second }, doload: function() { this.video = document.ge
telementbyid("my-video"); this.c1 = document.ge
telementbyid("my-canvas"); this.ctx1 = this.c1.getcontext("2d"); var self = this; this.video.addeventlistener("play", function() { self.width = self.video.width; self.height = self.video.height; self.timercallback(); }, false); }, computeframe: function() { this.ctx1.drawimage(this.video, 0, 0, this.width, ...
... html <video id="my-video" controls src="https://udn.realityripple.com/samples/6f/08625b424a.m4v"> </video> javascript var myvideo = document.ge
telementbyid('my-video'); myvideo.playbackrate = 2; playable code <video id="my-video" controls="true" width="480" height="270"> <source src="https://udn.realityripple.com/samples/5b/8cd6da9c65.webm" type="video/webm"> <source src="https://udn.realityripple.com/samples/6f/08625b424a.m4v" type="video/mp4"> </video> <div class="playable-buttons"> <input id="edit" type="button" value="edit" /> ...
... <input id="reset" type="button" value="reset" /> </div> <textarea id="code" class="playable-code"> var myvideo = document.ge
telementbyid('my-video'); myvideo.playbackrate = 2;</textarea> var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var edit = document.ge
telementbyid('edit'); var code = textarea.value; function setplaybackrate() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; setplaybackrate(); }); edit.addeventlistener('click', function() { textarea.focus(); }) textarea.addeventlistener('input', setplaybackrate); window.addeventlistener('load', setplaybackrate); note: try the playbackrate example live.
...And 2 more matches
HTML attribute: rel - HTML: Hypertext Markup Language
link not allowed not allowed dns-prefetch
tells the browser to preemptively perform dns resolution for the target resource's origin external resource not allowed not allowed external referenced document is not part of the same site as the current document.
... link link link manifest web app manifest link not allowed not allowed modulepreload
tells to browser to preemptively fetch the script and store it in the document's module map for later evaluation.
... dns-prefetch relevant for the <link> element both in the <body> and <head>, it
tells the browser to preemptively perform dns resolution for the target resource's origin.
...And 2 more matches
<input type="button"> - HTML: Hypertext Markup Language
ragraph = document.queryselector('p'); button.addeventlistener('click', updatebutton); function updatebutton() { if (button.value === 'start machine') { button.value = 'stop machine'; paragraph.textcontent = 'the machine has started!'; } else { button.value = 'start machine'; paragraph.textcontent = 'the machine is stopped.'; } } the script gets a reference to the htmlinpu
telement object representing the <input> in the dom, saving this refence in the variable button.
...e.pagex : e.clientx + (document.documen
telement.scrollleft ?
... document.documen
telement.scrollleft : document.body.scrollleft); cury = (window.event) ?
...And 2 more matches
<input type="time"> - HTML: Hypertext Markup Language
you can set a default value for the input by including a valid time in the value attribute when creating the <input> element, like so: <label for="appt-time">choose an appointment time: </label> <input id="appt-time" type="time" name="appt-time" value="13:30"> you can also get and set the date value in javascript using the htmlinpu
telement.value property, for example: var timecontrol = document.queryselector('input[type="time"]'); timecontrol.value = '15:30'; time value format the value of the time input is always in 24-hour format that includes leading zeros: hh:mm, regardless of the input format, which is likely to be selected based on the user's locale (or by the user agent).
... var starttime = document.ge
telementbyid("starttime"); var valuespan = document.ge
telementbyid("value"); starttime.addeventlistener("input", function() { valuespan.innertext = starttime.value; }, false); when a form including a time input is submitted, the value is encoded before being included in the form's data.
...its value can, however, still be changed by javascript code directly setting the htmlinpu
telement.value property.
...And 2 more matches
Browser detection using the user agent - HTTP
so, user agent sniffing is defini
tely not the way to go.
...indow) { hastouchscreen = true; // deprecated, but good fallback } else { // only as a last resort, fall back to user agent sniffing var ua = navigator.useragent; hastouchscreen = ( /\b(blackberry|webos|iphone|iemobile)\b/i.test(ua) || /\b(android|windows phone|ipad|ipod)\b/i.test(ua) ); } } if (hastouchscreen) document.ge
telementbyid("examplebutton").style.padding="1em"; as for the screen size, simply use window.innerwidth and window.addeventlistener("resize", function(){ /*refresh screen size dependent things*/ }).
...there a single instance of a dog box immedia
tely above a cat box, of course.
...And 2 more matches
CSP: script-src - HTTP
use this sparingly and defini
tely not for scripts.
... examples violation case given this csp header: content-security-policy: script-src https://example.com/ the following script is blocked and won't be loaded or executed: <script src="https://not-example.com/js/library.js"></script> note that inline event handlers are blocked as well: <button id="btn" onclick="dosomething()"> you should replace them with addeventlistener calls: document.ge
telementbyid("btn").addeventlistener('click', dosomething); unsafe inline script note: disallowing inline styles and inline scripts is one of the biggest security wins csp provides.
... however, if you absolu
tely have to use it, there are a few mechanisms that will allow them.
...And 2 more matches
Firefox user agent string reference - HTTP
mac os x version gecko user agent string mac os x on in
tel x86 or x86_64 mozilla/5.0 (macintosh; in
tel mac os x x.y; rv:10.0) gecko/20100101 firefox/10.0 mac os x on powerpc mozilla/5.0 (macintosh; ppc mac os x x.y; rv:10.0) gecko/20100101 firefox/10.0 linux linux is a more diverse platform.
...android versions 4 and above will report the version accura
tely.
.../5.0 (mobile; rv:26.0) gecko/26.0 firefox/26.0 tablet mozilla/5.0 (tablet; rv:26.0) gecko/26.0 firefox/26.0 tv mozilla/5.0 (tv; rv:44.0) gecko/44.0 firefox/44.0 device-specific mozilla/5.0 (mobile; nnnn; rv:26.0) gecko/26.0 firefox/26.0 device-specific user agent strings although it is strongly discouraged by mozilla, some handset manufacturers unfortuna
tely include a token in their device's ua string that represents their device id.
...And 2 more matches
Promise.all() - JavaScript
it rejects immedia
tely upon any of the input promises rejecting or non-promises throwing an error, and will reject with this first rejection message / error.
...it is typically used when there are multiple asynchronous tasks that are dependent on one another to complete successfully, as it does not wait and will reject immedia
tely upon any of the input promises rejecting.
...ronicity of promise.all this following example demonstrates the asynchronicity (or synchronicity, if the iterable passed is empty) of promise.all: // we are passing as argument an array of promises that are already resolved, // to trigger promise.all as soon as possible var resolvedpromisesarray = [promise.resolve(33), promise.resolve(44)]; var p = promise.all(resolvedpromisesarray); // immedia
tely logging the value of p console.log(p); // using settimeout we can execute code after the stack is empty settimeout(function() { console.log('the stack is now empty'); console.log(p); }); // logs, in order: // promise { <state>: "pending" } // the stack is now empty // promise { <state>: "fulfilled", <value>: array[2] } the same thing happens if promise.all rejects: var mixedpromises...
...And 2 more matches
Codecs used by WebRTC - Web media technologies
due to its low sample rate and sample size, g.711 audio quality is generally considered poor by modern standards, even though it's roughly equivalent to what a landline
telephone sounds like.
...this changes the order of preference of the codecs, letting you
tell webrtc to prefer a different codec over all others.
... default codecs unless otherwise specified, the default—or, more accura
tely, preferred—codecs requested by each browser's implementation of webrtc are shown in the table below.
...And 2 more matches
The "codecs" parameter in common media types - Web media technologies
0 0 0 yuv 4:4:4 1 0 0 yuv 4:2:2 1 1 0 yuv 4:2:0 1 1 1 yuv 4:0:0 (monochrome) the third digit in ccc indicates the chroma sample position, with a value of 0 indicating that the position is unknown and must be separa
tely provided during decoding; a value of 1 indicating that the sample position is horizontally colocated with the (0, 0) luma sample; and a value of 2 indicating that the sample position is colocated with (0, 0) luma.
... 58 00 main profile (mp) the profile used for standard-definition digital
television being broadcast in mpeg-4 format.
... not used for high-definition
television broadcasts.
...And 2 more matches
Navigation and resource timings - Web Performance
the document can now handle post-load tasks, after which point the document is marked as comple
tely loaded.
...the request start is the moment immedia
tely before the user agent starts requesting the resource from the server, or from relevant application caches or from local resources.
... the response start is the time immedia
tely after the user agent's http parser receives the first byte of the response from relevant application caches, or from local resources or from the server, which happens after the request is received and processed.
...And 2 more matches
SVG documentation index - SVG: Scalable Vector Graphics
versions of svg viewers prior to the release of firefox 1.5 unfortuna
tely paid scant attention to namespaces, but they are essential to multi-xml dialect supporting user agents such as gecko-based browsers which must be very strict.
...the image and its components can also be transformed, composited together, or filtered to change their appearance comple
tely.
... 288 texts intermediate, svg, svg:tutorial when talking about text in svg we have to differentiate two almost comple
tely separate topics.
...And 2 more matches
XPath snippets - XPath
anode.documen
telement : anode.ownerdocument.documen
telement); var result = xpe.evaluate(aexpr, anode, nsresolver, 0, null); var found = []; var res; while (res = result.iteratenext()) found.push(res); return found; } this function uses the new xpathevaluator() constructor, which is supported in firefox, chrome, opera and safari, but not in edge or internet explorer.
...scripts in a web document which might be accessed by edge or internet explorer users should replace the call to new xpathevaluator() with the following fragment: // xpathevaluator is implemented on objects that implement document var xpe = anode.ownerdocument || anode; in that case the creation of the xpathnsresolver can be simplified as: var nsresolver = xpe.creatensresolver(xpe.documen
telement); note however that creatensresolver should only be used if you are sure the namespace prefixes in the xpath expression match those in the document you want to query (and that no default namespace is being used (though see document.creatensresolver for a workaround)).
...if you can rely on id attributes, document.ge
telementbyid() is still powerful, but it's not nearly as powerful as xpath.
...And 2 more matches
page-worker - Archive of obsolete content
in this example we fetch the first paragraph of a page from wikipedia, then the first paragraph of a different page: var getfirstparagraph = "var paras = document.ge
telementsbytagname('p');" + "console.log(paras[0].textcontent);" + "self.port.emit('loaded');" pageworker = require("sdk/page-worker").page({ contentscript: getfirstparagraph, contenturl: "http://en.wikipedia.org/wiki/chalk" }); pageworker.port.on("loaded", function() { pageworker.contenturl = "http://en.wikipedia.org/wiki/cheese" }); scripting...
...this may take one of the following values: "start": load content scripts immedia
tely after the document element for the page is inserted into the dom, but before the dom content itself has been loaded "ready": load content scripts once dom content has been loaded, corresponding to the domcontentloaded event "end": load content scripts once all the content (dom, js, css, images) for the page has been loaded, at the time the window.onload event fires this prope...
...setting it loads the content immedia
tely.
...this may have one of the following values: "start": load content scripts immedia
tely after the document element for the page is inserted into the dom, but before the dom content itself has been loaded "ready": load content scripts once dom content has been loaded, corresponding to the domcontentloaded event "end": load content scripts once all the content (dom, js, css, images) for the page has been loaded, at the time the window.onload event fires contentscriptoptions read...
Label and description - Archive of obsolete content
absolu
tely nothing!</description> with white-space: pre; all whitespace, including newlines, is rendered literally.
...absolu
tely nothing!</description> with white-space: pre-wrap; all whitespace is rendered literally, but text is additionally permitted to wrap at spaces.
... absolu
tely nothing!</description> text can also be made to wrap by inserting an <html:br/> element regardless of the css style, but this creates a hard-break that does not change as parent elements resize.
... <description>i am your father's brother's nephew's cousin's former roommate.<html:br/> what's that make us?<html:br/> absolu
tely nothing!</description> using labels as anchors its possible to make a label look and act like an html <a> tag: <label class="text-link" href="http://whatever.com" value="click here to go to whatever"/> "text-link" is a built-in, predefined class.
JavaScript timers - Archive of obsolete content
the requestanimationframe() function
tells the browser that you wish to perform an animation and requests that the browser schedule a repaint of the window for the next animation frame.
... setimmediate() calls a function immedia
tely after the browser has completed other operations, such as events and display updates.
... requestanimationframe() requestanimationframe()
tells the browser that you wish to perform an animation and requests that the browser schedule a repaint of the window for the next animation frame.
...unfortuna
tely the canvas element was never designed to be used in this way (unlike flash) so there are limitations.
How to convert an overlay extension to restartless - Archive of obsolete content
mappings, so that you can access your files with custom paths such as: resource://myaddon/filename.ext chrome://myaddon/content/filename.ext step 2: no more resource:// uris for files internal to your bundle unfortuna
tely, resource mappings in your chrome.manifest were not usable in restartless add-ons until mozilla finally fixed this bug in firefox 38, which looked bad, but only because mozilla is still using resource:// uris internally and in examples.
...unfortuna
tely, the built in apis for dealing with preferences are missing this basic stuff, and its plain text handling doesn't work with unicode properly.
...docs: document.ge
telementbyid(), document.createelement(), element reference, node reference (dom elements are also nodes).
....nsidomwindow)); } var windowlistener = { onopenwindow: function(xulwindow) { var window = xulwindow.queryinterface(components.interfaces.nsiinterfacerequestor) .getinterface(components.interfaces.nsidomwindow); function onwindowload() { window.removeeventlistener("load",onwindowload); if (window.document.documen
telement.getattribute("windowtype") == "navigator:browser") loadintowindow(window); } window.addeventlistener("load",onwindowload); }, onclosewindow: function(xulwindow) { }, onwindowtitlechange: function(xulwindow, newtitle) { } }; as mentioned above, components.utils.unload() will not work properly if the jsm file it is unloading is in a jar.
JavaScript Object Management - Archive of obsolete content
the load event is fired after the dom on the window has loaded comple
tely, but before it's displayed to the user.
... */ init : function(aevent) { this._stringbundle = document.ge
telementbyid("xulschoolhello-string-bundle"); // you can make changes to the window dom here.
...if you really need to do something like this anyway, one way to do it is to have a timeout execute the code after a delay: init : function(aevent) { let that = this; this._stringbundle = document.ge
telementbyid("xs-hw-string-bundle"); window.settimeout( function() { window.alert(that._stringbundle.getstring("xulschoolhello.greeting.label")); }, 0); } the settimeout function executes the function in the first parameter, after a delay in miliseconds specified by the second parameter.
...all module files should begin with a declaration like this: var exported_symbols = ["〈modulenamespace〉"]; exported_symbols is a special identifier that
tells firefox that this file is only publishing the object named 〈modulenamespace〉.
Setting Up a Development Environment - Archive of obsolete content
ultima
tely you can just compress the contents of the src directory using any zip or archive tool and get a similar result.
...that is because make can
tell that the file in the bin directory is up to date, and nothing needs to be done.
...you can even change styles, attributes and execute javascript code in it, although that's not comple
tely reliable.
...it's defini
tely worth a try.
Adding preferences to an extension - Archive of obsolete content
next, we call our own refreshinformation() method to immedia
tely fetch and display the current information about the stock the extension is configured to monitor.
... once we've gotten the updated preference, we call refreshinformation() to immedia
tely update the display with the new stock's information.
... watchstock() while we're at it, let's add a method that sets which stock we want to be watching, changing the preference and immedia
tely requesting a refresh of the display.
...ation: function() { // because we may be called as a callback, we can't rely on // "this" referring to the right object, so we need to reference // it by its full name var symbol = stockwatcher.tickersymbol; var fullurl = "http://quote.yahoo.com/d/quotes.csv?f=sl1d1t1c1ohgv&e=.csv&s=" + symbol; function inforeceived() { var samplepanel = document.ge
telementbyid('stockwatcher2'); var output = httprequest.responsetext; if (output.length) { // remove any whitespace from the end of the string output = output.replace(/\w*$/, ""); // build the tooltip string var fieldarray = output.split(","); samplepanel.label = symbol + ": " + fieldarray[1]; samplepanel.tooltiptext = "chg: " + fi...
Creating a dynamic status bar extension - Archive of obsolete content
we use the window.addeventlistener() dom function to
tell firefox to call the stockwatcher.startup() function when a new browser window is opened: window.addeventlistener("load", function(e) { stockwatcher.startup(); }, false); our new extension has two primary functions: startup() and refreshinformation().
...refreshinformation() embeds another function, inforeceived(), which we'll look at separa
tely shortly.
...function inforeceived() { var samplepanel = document.ge
telementbyid('stockwatcher'); var output = httprequest.responsetext; if (output.length) { // remove whitespace from the end of the string; // this gets rid of the end-of-line characters output = output.replace(/\w*$/, ''); // build the tooltip string var fieldarray = output.split(','); // assert that fieldarray[0] == 'goog' samplepanel.label = 'goog: ' + fieldarray[1...
...]; samplepanel.tooltiptext = 'chg: ' + fieldarray[4] + ' | ' + 'open: ' + fieldarray[5] + ' | ' + 'low: ' + fieldarray[6] + ' | ' + 'high: ' + fieldarray[7] + ' | ' + 'vol: ' + fieldarray[8]; } } the first thing we do here is get the status bar panel into the variable samplepanel by calling the document.ge
telementbyid() dom function.
Using microformats - Archive of obsolete content
var nummicroformats = microformats.count(name, roo
telement, options); parameters name the name of the microformat to count.
... roo
telement required.
... var microformatsarray = microformats.get(name, roo
telement, options, targetarray); parameters name the name of the microformat to find.
... roo
telement required.
Menu - Archive of obsolete content
if the menu is visible, it will reflect the changes immedia
tely.
... show(anchornode) shows the menu immedia
tely.
...if a user forgets or is unable to
tell whether a certain menuitem is part of firefox or provided by a feature, she does not know where to turn when she has problems with it.
...notifications.show(menuitem.label) }); add an item to the hyperlink context menu that tweets the link: jetpack.menu.context.page.on("a").add(function (context) { return { label: "tweet", command: function () jetpack.lib.twitter.statuses.update({ status: context.node.href }) }; )); add an item to the page's context menu depending on some complex criteria that can't be comple
tely expressed via a css selector: jetpack.menu.context.page.beforeshow = function (menu, context) { menu.reset(); if (matchesmycriteria(context)) menu.add("match!"); }; add an item to both the hyperlink context menu and the image context menu: jetpack.menu.context.page.on("a, img").set("a link or image"); add an item to the image context menu, but only for images contained in hyperlinks: j...
Mozilla Crypto FAQ - Archive of obsolete content
at that point both nss and psm will be comple
tely buildable using the open source code available from the mozilla.org site, and nss and psm will be included in the mozilla binary releases distributed by mozilla.org.
...district court for the northern district of california issued a final ruling (written by judge marilyn hall pa
tel) that "the [u.s.
...bureau of export administration immedia
tely afterward, and the u.s.
...an earlier (circa 1995) collection of essays and public documents, with a concentration on the clipper chip controversy and the digital
telephony act.
New Security Model for Web Services - Archive of obsolete content
these scripts may legitima
tely require access to external resources, but permitting them to access internal resources permits the compromise of these resources that would normally not be available to applications outside of the firewall.
...but signed scripts have not really caught on as they require certificates do not change the basic problem that some comple
tely-unknown party has written a script that might now have access to internal resources.
...this could be combined with the other options above such as whi
telisting, signed scripts, etc.
... unfortuna
tely, this does not prevent soap messages from being sent to non-soap addresses, which is a big enough problem that the verification cannot stand alone to guarantee that untrusted service requests are always properly rejected by services that should be firewall-protected.
File object - Archive of obsolete content
file.wri
teln() write bytes to the file, followed by a line separator, flushing the buffer if file.hasautoflush.
... file.writeall() writes an array of lines to the file, obeying the same semantics as wri
teln.
... examples example: hello, world file.output.wri
teln("hello, world"); example: writing a new file var file = new file("myfile.txt"); file.open("write,create", "text"); file.wri
teln("the quick brown fox jumped over the lazy dogs"); file.close(); example: reading from a file var data; var file = new file("myfile.txt"); file.open("read", "text"); data = file.readln(); file.close(); example: sending mail through a pipeline var mail = new file("...
...|/usr/lib/sendmail foo@bar.com"); mail.wri
teln("i love javascript.\npipe support is especially good!"); mail.close(); ...
OpenClose - Archive of obsolete content
here is a complete example which uses a button to open a menu: <button label="open menu" oncommand="document.ge
telementbyid('editmenu').open = true;"/> <menu id="editmenu" label="edit"> <menupopup> <menuitem label="cut"/> <menuitem label="copy"/> <menuitem label="paste"/> </menupopup> </menu> this technique may be used for both menupopups that use the menu tag, the button tag and the toolbarbutton tag.
... somepopup.openpopup(document.documen
telement, "end_before", 0, 0, false, false); the second argument to openpopup is the anchor position, which specifies which side of the anchor the popup is positioned on.
...here is an example mouse click event listener: function mouseclicked(event) { var panel = document.ge
telementbyid("some-panel"); panel.openpopup(null, "", event.clientx, event.clienty, false, false); } the openpopupatscreen method a second method, openpopupatscreen, may be used to open up a popup and place it at a specific screen coordinate.
...in the following example, the popup is opened at horizontal positon 100 and vertical position 200: popup.openpopupatscreen(100, 200, false); note that if the supplied coordinates would cause the popup to be partially or comple
tely off screen, the popup will be moved such that it is fully visible, and may be resized if necessary.
Sorting and filtering a custom tree view - Archive of obsolete content
"sort(this)" class="sortdirectionindicator"/> <splitter class="tree-splitter"/> <treecol id="weapon" label="weapon" flex="1" persist="width ordinal hidden" onclick="sort(this)" class="sortdirectionindicator"/> </treecols> <treechildren id="tree-children"/> </tree> </window> sort.js var table = null; var data = null; var tree; var filtertext = ""; function init() { tree = document.ge
telementbyid("tree"); loadtable(); } //this function is called every time the tree is sorted, filtered, or reloaded function loadtable() { //remember scroll position.
...this way, we don't have to deal with //mapping between the two data.push({name: "leonardo", description: "leader", weapon: "dual katanas"}); data.push({name: "michaelangelo", description: "party dude", weapon: "nunchaku"}); data.push({name: "dona
tello", description: "does machines", weapon: "bo"}); data.push({name: "raphael", description: "cool, but rude", weapon: "sai"}); data.push({name: "splinter", description: "rat", weapon: "walking stick"}); data.push({name: "shredder", description: "armored man", weapon: "blades"}); data.push({name: "casey jones", description: "goalie masked man", weapon: "hockey stick"}); data.push({name: "...
..."ascending" : "descending"); tree.setattribute("sortresource", columnname); tree.view = new treeview(table); //set the appropriate attributes to show to indicator var cols = tree.ge
telementsbytagname("treecol"); for (var i = 0; i < cols.length; i++) { cols[i].removeattribute("sortdirection"); } document.ge
telementbyid(columnname).setattribute("sortdirection", order == 1 ?
... return o.tolowercase(); } return o; } function gettopvisiblerow() { return tree.treeboxobject.getfirstvisiblerow(); } function settopvisiblerow(topvisiblerow) { return tree.treeboxobject.scrolltorow(topvisiblerow); } function inputfilter(event) { //do this now rather than doing it at every comparison var value = prepareforcomparison(event.target.value); setfilter(value); document.ge
telementbyid("clearfilter").disabled = value.length == 0; } function clearfilter() { document.ge
telementbyid("clearfilter").disabled = true; var filterelement = document.ge
telementbyid("filter"); filterelement.focus(); filterelement.value = ""; setfilter(""); } function setfilter(text) { filtertext = text; loadtable(); } ...
Template Logging - Archive of obsolete content
fortuna
tely, some debugging and logging support is provided with templates that may help.
...however, calling ge
telementbyid using this id will retrieve the generated content for that result if you want to further study the content that was generated.
...we could debug this by removing parts of the query bottom up, for instance, removing the <triple> element comple
tely and seeing whether any results or content is generated.
...unfortuna
tely, detecting network or parsing errors with the data itself can be difficult.
Manipulating Lists - Archive of obsolete content
here is an example: example 1 : source view <script> function additem(){ document.ge
telementbyid('thelist').appenditem("thursday", "thu"); } </script> <listbox id="thelist"/> <button label="add" oncommand="additem();"/> the appenditem() takes two arguments, the label, in this case 'thursday', and a value 'thu'.
... example 3 : source view <script> function doselect(){ var val = document.ge
telementbyid('number').value; val = number(val); if (val != null) document.ge
telementbyid('level').selectedindex = val - 1; } </script> <hbox align="center"> <label value="enter a number from 1 to 3:"/> <textbox id="number"/> <button label="select" oncommand="doselect();"/> </hbox> <radiogroup id="level"> <radio label="excellent"/> <radio label="good"/> <radio label="poor"/> </r...
... deleting selected items the following example shows a method of deleting the selected items properly: example 4 : source view <script> function deleteselection(){ var list = document.ge
telementbyid('thelist'); var count = list.selectedcount; while (count--){ var item = list.selecteditems[0]; list.removeitemat(list.getindexofitem(item)); } } </script> <button label="delete" oncommand="deleteselection();"/> <listbox id="thelist" seltype="multiple"> <listitem label="cheddar"/> <listitem label="cheshire"/> <listitem label="edam"/> <listitem label="gouda"/> <li...
...compare the effect of both functions at different scroll positions in this example: example 5 : source view <button label="scrolltoindex" oncommand="document.ge
telementbyid('thelist').scrolltoindex(4);"/> <button label="ensureindexisvisible" oncommand="document.ge
telementbyid('thelist').ensureindexisvisible(4);"/> <listbox id="thelist" rows="5"> <listitem label="1"/> <listitem label="2"/> <listitem label="3"/> <listitem label="4"/> <listitem label="5"/> <listitem label="6"/> <listitem label="7"/> <listitem label="8"/> <listitem...
The Implementation of the Application Object Model - Archive of obsolete content
this gives you a feature called aggregation, the ability to put comple
tely different kinds of data into the same place.
...because the file lives remo
tely, it can be updated whenever the owner of the web site sees fit.
...the only way that one content node would know how to instantiate a content node of a comple
tely different type is if it had additional information stored for every child content node that it contained.
...let's consider another required feature that has heretofore gone unmentioned in this document: the need to take the same set of data and present it as comple
tely different content models.
datepicker - Archive of obsolete content
in addition, the date, month and year properties may be used to retrieve and modify each component of the date separa
tely.
... attributes disabled, firstdayofweek, readonly, type, tabindex, value properties date, da
teleadingzero, datevalue, disabled, month, monthleadingzero, open, readonly, tabindex, value, year, yearleadingzero examples <datepicker type="grid" value="2007-03-26"/> attributes disabled type: boolean indicates whether the element is disabled or not.
... da
teleadingzero type: boolean a read only value indicating whether a leading zero should be displayed before the date when it is less than 10.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
tab - Archive of obsolete content
afterselected type: boolean this is set to true if the tab is immedia
tely after the currently selected tab.
... beforeselected type: boolean this is set to true if the tab is immedia
tely before the currently selected tab.
...this would be useful if the images are stored remo
tely or you plan on swapping the image frequently.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
timepicker - Archive of obsolete content
in addition, the hour, minute and second properties may be used to retrieve and modify each component of the time separa
tely.
... attributes disabled, hideseconds, increment, readonly, tabindex, value properties amindicator, datevalue, disabled, hideseconds, hour, hourleadingzero, increment, is24hourclock, ispm, minute, minu
teleadingzero, pmindicator, readonly, second, secondleadingzero, tabindex, value examples <timepicker value="12:05"/> attributes disabled type: boolean indicates whether the element is disabled or not.
... minu
teleadingzero type: boolean a read only value indicating whether a leading zero should be displayed before the minute when it is less than 10.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
Creating XULRunner Apps with the Mozilla Build System - Archive of obsolete content
now you need to set up a special .mozconfig file to
tell mozilla to build both xulrunner and your application.
...moz_build_projects="xulrunner mccoy" mk_add_options moz_objdir=@topsrcdir@/../mccoybase # global options ac_add_options --enable-debug ac_add_options --disable-optimize # xulrunner options ac_add_app_options xulrunner --enable-application=xulrunner # mccoy options ac_add_app_options mccoy --enable-application=mccoy ac_add_app_options mccoy --with-libxul-sdk=../xulrunner/dist the first section
tells mozilla what to build and where to put the resulting object files.
...it
tells mozilla where to look for the build.mk file, which is what
tells it where to start building your app.
...makefiles.sh - you don't absolu
tely need this file since the build system will generate makefiles as need by walking the tree (based on the value of dirs).
Gecko Compatibility Handbook - Archive of obsolete content
in addition, internet explorer 4 and netscape navigator 4 use comple
tely different methods of embedding third-party software into the browser.
...unfortuna
tely, this is invalid html and can cause problems both when parsing the page and when applying the css styles.
... wrong doctype problem: an incorrect doctype can comple
tely alter a page's presentation.
...unfortuna
tely, several implementations of ssl 3.0 incorrectly implement the negotiation of which version of ssl to use and fail to connect to gecko browsers.
NPN_GetValue - Archive of obsolete content
play =1: unix only: returns the current display npnvxtappcontext: unix only: returns the application's xtappcontext npnvnetscapewindow: ms windows and unix/x11 only: ms windows: gets the native window on which plug-in drawing occurs; returns hwnd unix/x11: gets the browser toplevel window in which the plug-in is displayed; returns window npnvjavascriptenabledbool:
tells whether javascript is enabled; true=javascript enabled, false=not enabled npnvasdenabledbool:
tells whether smartupdate (former name: asd) is enabled; true=smartupdate enabled, false=not enabled npnvisofflinebool:
tells whether offline mode is enabled; true=offline mode enabled, false=not enabled npnvtoolkit: npnvsupportsxembedbool: npnvwindownpobject: returns the npobject * poin...
...ter for the dom window object; see getting the page url in npapi plugin for a rough example npnvpluginelementnpobject: npnvsupportswindowless:
tells whether the browser supports windowless plugins.
... the value parameter should point to a npbool, which will be set appropria
tely if the function returns nperr_no_error.
...the value parameter should point to an npbool, which will be set appropria
tely if the function returns nperr_no_error.
NPAPI plugin reference - Archive of obsolete content
browser-side plug-in api this chapter describes methods in the plug-in api that are provided by the browser; these allow call back to the browser to request information,
tell the browser to repaint part of the window, and so forth.
... npn_forceredraw asks the plugin host to immedia
tely (synchronously) repaint invalid areas.
... npp_destroystream
tells the plug-in that a stream is about to be closed or destroyed.
... npp_setwindow
tells the plug-in when a window is created, moved, sized, or destroyed.
Introduction to Public-Key Cryptography - Archive of obsolete content
while in transit, the encrypted information is unin
telligible to an intruder.
...the user must supply a name and password separa
tely for each new server the user wishes to use during a work session.
... contents of a certificate the contents of certificates are organized according to the x.509 v3 certificate specification, which has been recommended by the international
telecommunications union (itu), an international standards body, since 1988.
... depending on an organization's policies, the process of issuing certificates can range from being comple
tely transparent for the user to requiring significant user participation and complex procedures.
Using workers in extensions - Archive of obsolete content
when the result is received from xmlhttprequest, instead of immedia
tely updating the displayed information in the status bar, a message is sent to the main thread using the worker's postmessage() method.
... line 22 sends a message to the ticker thread to
tell it what symbol to monitor.
...it needs to be updated to post a message to the worker to
tell it which stock symbol to track.
...watchstock() is updated to pass the symbol to the ticker thread, and refreshinformation(), whose main functionality is now in the worker, is updated to simply pass an empty message to the worker, which
tells the worker to refresh the stock information immedia
tely.
Back to the Server: Server-Side JavaScript On The Rise - Archive of obsolete content
listing 5 - demonstration of server-proxy <script runat="server"> function notexposed() { // runs on the server, hidden from the browser return "can't see me!"; } function exposed() { // runs on the server, callable from the browser return "exposed to the browser"; } exposed.proxy = true; //
tell jaxer this function is ok to be called from the browser </script> <script runat="client" type="text/javascript"> alert( exposed() ); //works like a charm alert( notexposed() ); //produces an object not found error since it server-side only </script> understanding the concept of operating context in jaxer is central to moving forward with the example application which is wh...
... listing 7 - manipulating the dom server-side <script runat="server"> window.onserverload = function() { document.ge
telementbyid( "out-logger" ).innerhtml = jaxer.file.read( "dump.txt" ); } </script> the code in listing 7 is executed server-side and takes advantage of the onserverload event which ensures that we have a complete dom before trying to access it.
... <script> function formhandler() { // get the form values var name = txt_name.getvalue(); var email = txt_email.getvalue(); var message = txt_message.getvalue(); // if the form passes validation client-side, submit results to the processor if( validatecomments( name, email, message ) ) { formprocessor( name, email, message ); // update the logger with the most recent entry document.ge
telementbyid( "out-logger" ).innerhtml += "name: " + name + "<br/>email: " + email + "<br/>message: " + message + "<br/><br/>"; } else { ext.msg.alert( "error", "please enter the required fields" ); } } </script> <!-- processes the form contents --> <script runat="server"> function formprocessor( name, email, message ) { // perform the same validation of the data server-side if( !validatecomme...
... listing 10 - creating a simple xml service <script runat="server"> var rs_comments = jaxer.db.execute("select * from comments"); var doc = document.implementation.createdocument('', 'comments', null); var root = doc.documen
telement; rs_comments.rows.foreach(function(row, index) { if (true || index < 10) { var node = doc.createelement('comment'); node.setattribute('id', row.id); node.setattribute('name', row.name); node.setattribute('message', row.message); root.appendchild(node); } }); jaxer.response.exit(200, doc); </script> the data from the database is represented in xml format as follows: <comments> <comment mes...
Writing JavaScript for XHTML - Archive of obsolete content
problem: names in xhtml and html are represented in different cases scripts that used ge
telementsbytagname() with an upper case html name no longer work, and attributes like nodename or tagname return upper case in html and lower case in xhtml.
... solution: use or convert to lower case for methods like ge
telementsbytagname(), passing the name in lower case will work in both html and xhtml.
...so if the browser
tells our server, that it can handle xhtml as xml, that is, the accept: field in the http head contains application/xhtml+xml somewhere, we are safe to send the content as xml.
...ss here is the accept field, that firefox 2.0.0.9 sends with its requests: accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 further reading you will find several useful articles in the developer wiki: xml in mozilla dom xml introduction xml extras dom 2 methods you will need are: dom:document.createelementns dom:document.ge
telementsbytagnamens see also properly using css and javascript in xhtml documents ...
Parsing microformats in JavaScript - Archive of obsolete content
telgetter() specifically retrieves a
telephone number from a microformat node.
... this handles the fact that
telephone numbers use "value" as the name of one of their subproperties, but "value" is also used for value excerpting.
...
tel = microformats.parser.
telgetter(propnode, parentnode); parameters propnode the dom node to check.
... return value a string containing the
telephone number.
Audio for Web games - Game development
unfortuna
tely these are also the platforms that people often use to play games.
...also note that playing and immedia
tely pausing your audio does not guarantee that a small piece of audio won't be played.
... let's add some javascript to make this work: var myaudio = document.ge
telementbyid('myaudio'); var buttons = document.ge
telementsbytagname('button'); var stoptime = 0; for (var i = 0; i < buttons.length; i++) { buttons[i].addeventlistener('click', function() { myaudio.currenttime = this.getattribute("data-start"); stoptime = this.getattribute("data-stop"); myaudio.play(); }, false); } myaudio.addeventlistener('timeupdate', function() { if (this.curr...
... note: if the first parameter is 0 or less than the context currenttime, playback will commence immedia
tely.
Mobile touch controls - Game development
overview: control mechanisms next the future of mobile gaming is defini
tely web, and many developers choose the mobile first approach in their game development process — in the modern world, this generally also involves implementing touch controls.
... pure javascript approach we could implement touch events on our own — setting up event listeners and assigning relevant functions to them would be quite straightforward: var el = document.ge
telementsbytagname("canvas")[0]; el.addeventlistener("touchstart", handlestart); el.addeventlistener("touchmove", handlemove); el.addeventlistener("touchend", handleend); el.addeventlistener("touchcancel", handlecancel); this way, touching the game's <canvas> on the mobile screen would emit events, and thus we could manipulate the game in any way we want (for example, moving the space ship around).
...you can assign functions on input down and input up separa
tely if you'd like to perform more complicated actions, but in this game touching the right side of the screen will simply fire the bullets to the right — this is all we need in this case.
... the stick being pressed can be handled during the gameplay in the update function like so: if(this.stick.isdown) { // move the player } we can adjust the player's velocity based on the current angle of the stick and move him appropria
tely.
IIFE - MDN Web Docs Glossary: Definitions of Web-related terms
an iife (immedia
tely invoked function expression) is a javascript function that runs as soon as it is defined.
... the second part creates the immedia
tely invoked function expression () through which the javascript engine will directly interpret the function.
... examples the function becomes a function expression which is immedia
tely executed.
... var result = (function () { var name = "barry"; return name; })(); // immedia
tely creates the output: result; // "barry" ...
XInclude - MDN Web Docs Glossary: Definitions of Web-related terms
(note that this has not been thoroughly tested for all circumstances and may not necessarily reflect the standard behavior comple
tely.) note also that if you wish to allow xml:base, you will need the xml:base function, and the line beginning var href = ...
... should become: var href = getxmlbaselink (/* xlink sans xml:base */ xinclude.getattribute('href'), /* element to query from */ xinclude); function resolvexincludes(docu) { // http://www.w3.org/tr/xinclude/#xml-included-items var xincludes = docu.ge
telementsbytagnamens('http://www.w3.org/2001/xinclude', 'include'); if (xincludes) { for (i=0; i < xincludes.length; i++) { var xinclude = xincludes[i]; var href = xinclude.getattribute('href'); var parse = xinclude.getattribute('parse'); var xpointer = xinclude.getattribute('xpointer'); var encoding = xinclude.getattribute('encoding'); // e.g., utf-8 // "text/xml or application/xml or matches text/*+xml or application/*+xml" before encoding (then utf-8) v...
...ar accept = xinclude.getattribute('accept'); // header "accept: "+x var acceptlanguage = xinclude.getattribute('accept-language'); // "accept-language: "+x var xifallback = xinclude.ge
telementsbytagnamens('http://www.w3.org/2001/xinclude', 'fallback')[0]; // only one such child is allowed if (href === '' || href === null) { // points to same document if empty (null is equivalent to empty string) href = null; // set for uniformity in testing below if (parse === 'xml' && xpointer === null) { alert('there must be an xpointer attribute present if "href" is empty an parse is "xml"'); return false; } } else if (href.match(/#$/, '') || href.match(/^#/, '...
... 0; k < xpathresult.snapshotlength; k++) { a[k] = xpathresult.snapshotitem(k); } responsenodes = a; } else { // otherwise, the response must be a single well-formed document response responsenodes = [response.documen
telement]; // put in array so can be treated the same way as the above } // prepend any node(s) (as xml) then remove xinclude for (j=0; j < responsenodes.length ; j++) { xincludeparent.insertbefore(responsenodes[j], xinclude); } xi...
Practical positioning examples - Learn web development
vestibulum et orci scelerisque, vulputate
tellus quis, lobortis dui.
...the <a> elements are set to display inline-block so they will sit in a line but still be stylable, and they are styled appropria
tely for tab buttons, using a variety of other properties.
...the first rule we'll add will absolu
tely position the panels, and make them all sit flush to the top and left of their <div> container — this part is absolu
tely key to this whole layout feature, as it makes the panels sit on top of one another.
...don't worry if you didn't get this all immedia
tely — positioning is a fairly advanced topic, and you can always work through the articles again to aid your understanding.
Responsive design - Learn web development
zoe mickley gillenwater was instrumental in her work to describe and formalize the different ways in which flexible sites could be created, attempting to find a happy medium between filling the screen or being comple
tely fixed in size.
...whether the user's screen is greater than a certain width, or a certain resolution) and apply css selectively to style the page appropria
tely for the user's needs.
... you can also art direct images used at different sizes, thus providing a different crop or comple
tely different image to different screen sizes.
... <meta name="viewport" content="width=device-width,initial-scale=1"> this meta tag
tells mobile browsers that they should set the width of the viewport to the device width, and scale the document to 100% of its intended size, which shows the document at the mobile-optimized size that you intended.
How do you make sure your website works properly? - Learn web development
resources like webpagetest.org or browser add-ons like yslow can
tell you a few interesting things: grades go from a to f.
... ping is a useful shell tool that tests the domain name you provide and
tells you if the server's responding or not: $ ping mozilla.org ping mozilla.org (63.245.215.20): 56 data bytes 64 bytes from 63.245.215.20: icmp_seq=0 ttl=44 time=148.741 ms 64 bytes from 63.245.215.20: icmp_seq=1 ttl=44 time=148.541 ms 64 bytes from 63.245.215.20: icmp_seq=2 ttl=44 time=148.734 ms 64 bytes from 63.245.215.20: icmp_seq=3 ttl=44 time=147.857 ms ^c --- mozilla.org ping statistics --- 4 packets transmitted, 4 pa...
... ctrl+c sends an “interrupt” signal to the runtime and
tells it to stop.
... if you don't stop the runtime, ping will ping the server indefini
tely.
The HTML5 input types - Learn web development
it is a helpful aid to guide users to fill out a form accura
tely, and it can save time — it is useful to know that your data is not correct immedia
tely, rather than having to wait for a round trip to the server.
... phone number field a special field for filling in phone numbers can be created using
tel as the value of the type attribute: <input type="
tel" id="
tel" name="
tel"> when accessed via a touch device with a dynamic keyboard, most devices will display a numeric keypad when type="
tel" is encountered, meaning this type is useful whenever a numeric keypad is useful, and doesn't just have to be used for
telephone numbers.
...if the range is too large for incremental increases to make sense (such as usa zip codes, which range from 00001 to 99999), the
tel type might be a better option; it provides the numeric keypad while forgoing the number's spinner ui feature.
...then we immedia
tely set the output's textcontent to the current value of the input.
UI pseudo-classes - Learn web development
to fix this we style the parent <div> to become a flex container, but also
tell it to wrap its contents onto new lines if the content becomes too long: fieldset > div { margin-bottom: 20px; display: flex; flex-flow: row wrap; } the effect this has is that the label and input sit on separate lines because they are both width: 100%, but the <span> has a width of 0 so can sit on the same line as the input.
...we then absolu
tely position different generated content depending on whether the form's data is valid or invalid — a green check or a red cross, respectively.
... now finally, we've used some javascript to toggle the disabling of the billing address fields: // wait for the page to finish loading document.addeventlistener('domcontentloaded', function () { // attach `change` event listener to checkbox document.ge
telementbyid('billing-checkbox').addeventlistener('change', togglebilling); }, false); function togglebilling() { // select the billing text fields let billingitems = document.queryselectorall('#billing input[type="text"]'); // select the billing text labels let billinglabels = document.queryselectorall('.billing-label'); // toggle the billing text fields and labels for (let i = 0; i < ...
...one use case could be an indicator to
tell users that they really need to select a radio button before they move on.
Tips for authoring fast-loading HTML pages - Learn web development
then you just apply the same image each time you need it for a background and adjust the x/y coordinates appropria
tely.
... specify sizes for images and tables if the browser can immedia
tely determine the height and/or width of your images and tables, it will be able to display a web page without having to reflow the content.
...switching to lazy loading of images
tells the browser to hold off on loading images until they're about to be needed to draw the visual viewport.
...interaction scripts typically can only run after the page has comple
tely loaded and all necessary objects have been initialized.
Arrays - Learn web development
if we didn't have arrays, we'd have to store every item in a separate variable, then call the code that does the printing and adding separa
tely for each item.
...try the following: shopping.length; // should return 5 this has other uses, but it is most commonly used to
tell a loop to keep going until it has looped through all the items in an array.
... 4 // number 5 let itemtext = 0; const listitem = document.createelement('li'); listitem.textcontent = itemtext; list.appendchild(listitem); } totalbox.textcontent = 'total: $' + total.tofixed(2); </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
...us(); } } </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
What went wrong? Troubleshooting JavaScript - Learn web development
sure enough, loworhi's value is null at this point, so there is defini
tely a problem with line 48.
... syntax errors round three now if you try playing the game through again, you should get more success — the game should play through absolu
tely fine, until you end the game, either by guessing the right number, or by running out of guesses.
...defini
tely not quite how we want the game to play out!
... there's defini
tely a problem in the game logic somewhere — the game is not returning an error; it just isn't playing right.
Aprender y obtener ayuda - Learn web development
for example: materials i need: a computer internet access pens and paper knowledge i need: how to use html, css, javascript, and associated tools and best practices to build web sites and web applications (we can defini
tely help you with this one!).
...don't try to work in a room with distractions — for example a
television on, with your friends watching football!
... style hover/focus/active states of menu items appropria
tely.
...for example, professional web developers have created lots of horizontal navigation menus, so they'll immedia
tely start thinking of a solution like this: a nav menu is usually created from a list of links, something like: <ul> <li>first menu item</li> <li>second menu item</li> <li>third menu item</li> <li>etc.</li> </ul> to make all the items sit horizontally on a line, the easiest modern way is to use flexbox: ul { display: flex; } to remove unneeded spacing and bullet points, we can do thi...
Server-side web frameworks - Learn web development
the model doesn't state any information about the underlying database as that is a configuration setting that may be changed separa
tely of our code.
...if you're starting from absolu
tely no programming experience then consider django (it is one of the easiest to learn based on the above criteria).
... built-in testing facility and code formatter (deno fmt) (javascript) browser compatibility: deno programs that are written comple
tely in javascript excluding the deno namespace (or feature test for it), should work directly in any modern browser.
... although defini
tely not the only framework based on java it is easy to use to create stand-alone, production-grade spring-based applications that you can "just run".
Website security - Learn web development
a reflected xss vulnerability occurs when user content that is passed to the server is returned immedia
tely and unmodified for display in the browser.
...however, a malicious user could comple
tely change the behavior of this sql statement to the new statement in the following example, by simply specifying the text in bold for the username.
...by putting a backslash in front of this character (\'), we escape the symbol, and
tell sql to instead treat it as a character (just a part of the string).
...clickjacking could also be used to get the user to click a button on a visible site, but in doing so actually unwittingly click a comple
tely different button.
Beginning our React todo list - Learn web development
we have a heading that
tells us how many tasks remain.
...for example: <button type="button" classname="btn toggle-btn" aria-pressed="true"> <span classname="visually-hidden">show </span> <span>all</span> <span classname="visually-hidden"> tasks</span> </button> here, aria-pressed
tells assistive technology (like screen readers) that the button can be in one of two states: pressed or unpressed.
... the aria-labelledby attribute
tells assistive technologies that we're treating our list heading as the label that describes the purpose of the list beneath it.
... finally, the labels and inputs in our list items have some attributes unique to jsx: <input id="todo-0" type="checkbox" defaultchecked={true} /> <label classname="todo-label" htmlfor="todo-0"> eat </label> the defaultchecked attribute in the <input/ > tag
tells react to check this checkbox initially.
Componentizing our Svelte app - Learn web development
you'll notice that when you click on the filter buttons, they are selected and the style updates appropria
tely.
... using bind, we will
tell svelte that any changes made to the filter prop in the filterbutton component should propagate back up to the parent component, todos.
...in addition, the remove event listener is sending the daa change back up to the parent, so our "x out of y items completed" status heading will now update appropria
tely when todos are deleted.
...and our "x out of y items completed" status heading will now update appropria
tely when todos are completed.
Dynamic behavior in Svelte: working with variables and props - Learn web development
observe how the numbers in the message are updated appropria
tely.
... so with export let todos = [], we are
telling svelte that our todos.svelte component will accept a todos attribute, which when omitted will be initialized to an empty array.
... we can
tell svelte that we want our totaltodos and completedtodos variables to be reactive by prefixing them with $:.
...in this case, the preventdefault modifier
tells svelte to generate the code to call event.preventdefault() before running the handler.
Creating our first Vue component - Learn web development
this will
tell vue that we expect every instance of this component to have a label field.
...this
tells vue that we expect the value of this property to be a string.
...this
tells vue we expect the value prop to be a javascript boolean type.
...this is to keep the data values unique for each instance of a component at runtime — the function is invoked separa
tely for each component instance.
Handling common HTML and CSS problems - Learn web development
in our debugging html and debugging css articles, we provided some really basic guidance on debugging html/css — if you are not familiar with the basics, you should defini
tely study these articles before carrying on.
...if a browser encounters a declaration or rule it doesn't understand, it just skips it comple
tely without applying it or throwing an error.
... this sounds like a pain to deal with, but fortuna
tely there is a polyfill available that does the necessary fixes for you, and more besides — see html5shiv for all the details (see manual installation for the simplest usage).
... store a reference to this element in a variable, for example: const test = document.ge
telementbyid('hplogo'); now try to set a new value for the css property you are interested in on that element; you can do this using the style property of the element, for example try typing these into the javascript console: test.style.transform = 'rotate(90deg)' test.style.webkittransform = 'rotate(90deg)' as you start to type the property name representation after the second dot (note tha...
Handling common JavaScript problems - Learn web development
if you want this to work correctly, you need to define a function to add the handler separa
tely, calling it on each iteration and passing it the current value of para and i each time (or something similar).
... using the javascript debugger unfortuna
tely, we still have the same error — the problem has not gone away.
...to give you a clue, you can either
tell the xmlhttprequest object explicitly to return json format, or convert the returned text to json after the response arrives.
...this all made browser sniffing even more error prone, and ultima
tely pointless.
Strategies for carrying out testing - Learn web development
by coding defensively, we mean trying to build in in
telligent fallbacks so that if a feature or style doesn't work in a browser, the site will be able to downgrade to something less exciting that still provides an acceptable user experience — the core information is still accessible, for example, even if it doesn't look quite as nice.
...of course, this relies on you already having a site to use it on, so it isn't much good for comple
tely new sites.
...you should defini
tely include accessibility as a grade a testing requirement (we'll cover exactly what you should test in our handling common accessibility problems article) plus you might have other considerations.
...this unfortuna
tely only runs on a mac.
Command line crash course - Learn web development
windows has traditionally had its own terminal-like program called cmd (“the command prompt”) for a long time, but this defini
tely doesn’t have parity with unix commands, and is equivalent to the old-style windows dos prompt.
...fortuna
tely, a small change to the command usage can give you a lot more information.
...try it now: curl /docs/web/api/fetch we need to explicitly
tell curl to follow redirects using the -l flag.
... the vast ecosystem of installable tools for front end web development currently exists mostly inside npm, a priva
tely owned, package hosting service that works closely together with node.js.
Multiprocess on Windows
unfortuna
tely this topic is often poorly explained.
...unfortuna
tely, crossing apartment boundaries using com incurs the exact same problem as crossing process boundaries: if we directly use com's built in marshaling capabilities to forward an rpc from the mta to the main thread sta, com will still use the sta's message queue, thus defeating the purpose of using the mta in the first place!
...without the support for length_is and size_is annotations, the interceptor cannot
tell the difference between a scalar outparam and an array outparam.
...this should usually be set to vt_unknown | vt_byref, which is
telling the interceptor that the outparam is an iunknown**.
Mozilla’s UAAG evaluation report
also, in the overwhelming majority of cases, the filename is unin
telligible.
...(p2) p our interface for image toggling needs redesign unfortuna
tely, there are quite a few open bugs on image toggling guideline 4.
...unforutuna
tely, some are hard coded.
... unfortuna
tely, switching profiles requires the entire application to be relaunched.
mach
it's a python script that creates an instance of the mach core, registers commands with it, then
tells the mach core to execute.
... the decorators are: @commandprovider this is a class decorator that
tells mach that this class contains methods that implement mach commands.
... @command this is a method decorator that
tells mach that this method implements a mach command.
... @commandargument this is a method decorator that
tells mach about an argument to a mach command.
Performance
performance best practices declaring sta
teless functions once per process bad: // addon.js services.mm.loadframescript("framescript.js", true) // framescript.js const precomputedconstants = // ...
...sage.target result = helper(frameglobal.content, message.data) frameglobal.sendasyncmessage("my-addon:response-from-child", {something: result}) } function addframe(frameglobal) { frameglobal.addmessagelistener("my-addon:request-from-parent", dosomething) } javascript modules are per-process singletons and thus all their objects are only initialized once, which makes them suitable for sta
teless callbacks.
...not only does that increase memory footprint but the deserialization also has to be executed sepera
tely for each tab, thus requiring more cpu time.
...um) } tabmm.addmessagelistener("my-addon:paragraph-count", callback); tabmm.loadframescript("data:,sendasyncmessage('my-addon:paragraph-count', {num: content.document.queryselectorall('p').length})", false) } function decoratebutton(button, count) { // do stuff with result } this executes the script only when it is needed and only in one tab and allows it to be garbage-collected immedia
tely after execution.
IPDL Tutorial
because protocol messages are represented as c++ methods, it's easy to forget that they are in fact asynchronous messages: by default the c++ method will return immedia
tely, before the message has been delivered.
...the message is sent, and the c++ method returns immedia
tely.
...if you absolu
tely need to block on a reply, use sync semantics very carefully.
...any time a message implementation returns false, ipdl will immedia
tely begin catastrophic error handling: the communication channels for the child process (tab or plugin) will be disconnected, and the process will be terminated.
Addon
overview of required methods void iscompatiblewith(in string appversion, in string platformversion) void findupdates(in upda
telistener listener, in integer reason, in string appversion, in string platformversion) overview of optional methods void uninstall() void canceluninstall() boolean hasresource(in string path) nsiuri getresourceuri(in string path) void getdatadirectory(in datadirectorycallback callback) required properties attribute type de...
...for some add-ons this will change immedia
tely based on the appdisabled and userdisabled properties; for others it will only change after an application restart.
... void findupdates( in upda
telistener listener, in integer reason, in string appversion, in string platformversion ) parameters listener an upda
telistener for the update process reason a reason code for performing the update appversion an application version to check for updates for platformversion a platform version to check for updates for optional methods uninstall() uninstalls this add-on.
... if possible the uninstall will happen immedia
tely, otherwise it will wait until the next application restart.
Log.jsm
expect these to be immedia
tely visible on a status console.
...expect these to be immedia
tely visible on a status console.
...expect these to be immedia
tely visible on a status console.
...expect these to be immedia
tely visible on a console, so be conservative and keep to a minimum.
Localization content best practices
for example, suppose this string needs to be changed from "event" to "add new event": new-event-header = event add-new-event-header is defini
tely a better choice for the new string than new-event-header1.
... create localizable strings don't assume grammar structures you need to consider the need for different grammar structures in different locales, and add switching mechanisms to present them appropria
tely.
...unfortuna
tely, this won't work at all: you need at least a third string to place after the link, without that some languages won't be able to create a natural sounding sentence.
...if you have doubts about the localizability of some text or structure (not about the text itself, that would need copywriters), it's defini
tely good to ask feedback.
Release phase
consequently, if you already have a local clone that you pulled using http, you'll need to modify a config file to
tell mercurial to push through ssh.
...configuration before you try pushing, you need to
tell ssh which username you wish to use for connecting with hg.mozilla.org.
... the following lines to your ~/.ssh/config file, replacing user@host.domain with your mozilla ldap account name: host hg.mozilla.org user user@host.domain if you have already cloned the remote repository using the http protocol using this command: $ hg clone http://hg.mozilla.org/releases/l10n-central/x-testing then you will need to edit the .hg/hgrc file (inside the x-testing local clone) to
tell mercurial to push using ssh.
... if you don't see this message, try running the same command in a more verbose mode (with the debugging information): $ ssh -vvv hg.mozilla.org this should
tell you why your connection is not succeeding.
Memory reporting
this is most obviously used in about:memory and
telemetry.
...this is important because sometimes an object might be embedded in another object that is measured separa
tely.
...because you want to show them separa
tely in about:memory.
... dmd is absolu
tely crucial; these things cannot be done without it.
Build instructions
ns_use_gcc: on platforms where gcc is not the native compiler,
tells nss to build with gcc instead of the native compiler.
... use_64: on platforms that support both 32-bit and 64-bit abis,
tells nss to build for the 64-bit abi.
... moz_debug_symbols:
tells nss to build with debug symbols, even in an optimized build.
... on windows, in both debug and optimized builds, when using msvc,
tells nss to put symbols in a .pdb file.
NSS functions
mxr 3.2 and later cert_decodeprivkeyusageperiodextension mxr 3.10 and later cert_decodetruststring mxr 3.4 and later cert_decodeusernotice mxr 3.2 and later cert_dernametoascii mxr 3.4 and later cert_destroycertarray mxr 3.2 and later cert_destroycertificate mxr 3.2 and later cert_destroycertifica
telist mxr 3.2 and later cert_destroycertificatepoliciesextension mxr 3.2 and later cert_destroycertificaterequest mxr 3.2 and later cert_destroycertlist mxr 3.2 and later cert_destroyname mxr 3.2 and later cert_destroyocspcertid mxr 3.6 and later cert_destroyocsprequest mxr 3.6 and later cert_des...
...indslotbyname mxr 3.2 and later pk11_findslotsbynames mxr 3.9 and later pk11_fortezzahaskea mxr 3.2 and later pk11_fortezzamapsig mxr 3.2 and later pk11_freeslot mxr 3.2 and later pk11_freeslotlist mxr 3.2 and later pk11_freeslotlis
telement mxr 3.11 and later pk11_freesymkey mxr 3.2 and later pk11_generatefortezzaiv mxr 3.2 and later pk11_generatekeypair mxr 3.2 and later pk11_generatekeypairwithflags mxr 3.10.2 and later pk11_generatekeypairwithopflags mxr 3.12 and later ...
... mxr 3.2 and later nssbase64_encodeitem mxr 3.4 and later nssbase64encoder_create mxr 3.2 and later nssbase64encoder_destroy mxr 3.2 and later nssbase64encoder_update mxr 3.2 and later nssrwlock_destroy mxr 3.2 and later nssrwlock_havewri
telock mxr 3.2 and later nssrwlock_lockread mxr 3.2 and later nssrwlock_lockwrite mxr 3.2 and later nssrwlock_new mxr 3.2 and later nssrwlock_unlockread mxr 3.2 and later nssrwlock_unlockwrite mxr 3.2 and later nsssmime_versioncheck ...
... 3.3 and later sec_pkcs7encodeitem mxr 3.9.3 and later sec_pkcs7encoderabort mxr 3.9 and later sec_pkcs7encoderfinish mxr 3.2 and later sec_pkcs7encoderstart mxr 3.2 and later sec_pkcs7encoderupdate mxr 3.2 and later sec_pkcs7getcertifica
telist mxr 3.2 and later sec_pkcs7getcontent mxr 3.2 and later sec_pkcs7getencryptionalgorithm mxr 3.2 and later sec_pkcs7getsignercommonname mxr 3.4 and later sec_pkcs7getsigneremailaddress mxr 3.4 and later sec_pkcs7getsigningtime mxr 3.4 and later ...
Hacking Tips
since there isn't debug info for the jitted code, you will need to
tell gdb that you are looking at arm code: (gdb) set arm force-mode arm or you can wrap the x command in your own command: def xi set arm force-mode arm eval "x/%di %d", $arg0, $arg1 set arm force-mode auto end printing asm.js/wasm generated assembly code (from gdb) set a breakpoint on js::wasm::instance::callexport (defined in wasminstance.cpp as of november 18th 2016).
... $ valgrind --smc-check=all-non-file --vex-iropt-register-updates=allregs-at-mem-access --vgdb-error=0 ./js … this command will
tell you how to start gdb as a remote.
... $ cgset -r cpuset.mems=0 /benchmarks $ cgset -r cpuset.mems=0 /benchmarks/mask $ cgset -r cpuset.mems=0 /benchmarks/negate-mask then we limit the performance of the cpu, as a proportion such as the result approxima
tely correspond to what you might have if you were running on a phone.
... for example an unagi is approxima
tely 40 times slower than my computer.
Property cache
entry->vcap caches the results of part 1 above,
telling which object contains the desired property.
...jsobject::objshape
tells an object's shape.
...
teleportation.
...the jit code "
teleports" directly to the appropriate object.
Finishing the Component
* * a user of a service may keep references to particular services * indefini
tely and only must call release when it shuts down.
...also, provides access to the url that are whi
telisted.
... if you care to extend this implementation so that the list of urls is held remo
tely on a server somewhere - as might be the case when the weblock component is used in a corporate intranet, for example - there are networking apis in gecko that will support this.
...if the scheme isn't "http", "https", or "ftp", it immedia
tely returns true, which continues the loading process unblocked.
Setting up the Gecko SDK
the following four sections
tell the developer how to download and organize the gecko sdk and create a new project in which components like weblock can be created.
... environment setup you can create a batch file to set up the environment for you, but this example
tells you from the command prompt.
... set lib=c:\program files\microsoft sdks\windows\v7.0\lib;c:\program files (x86)\microsoft visual studio 9.0\vc\lib;d:\projects\xulrunner-sdk\lib this
tells the linker where the default libraries to bind to are.
... this allows you to created the component without sending any extra dlls set path=%path%;d:\projects\xulrunner-sdk\sdk\bin;d:\projects\xulrunner-sdk\bin this
tells the command prompt where to find the gecko tools, importantly (xpidl, regxpcom, and gmake).
Using XPCOM Components
the iweblock interface lock lock the browser to the current site (or to the whi
telist of approved sites read from disk).
... addsite add a new site to the whi
telist.
... removesite remove a given site from the whi
telist.
... sites enumerator for the list of approved sites read in from the whi
telist.
XPCOM Stream Guide
most streams are asynchronous: they make no assumptions that all the data a resource provides is available immedia
tely.
...from the nsirequestobserver interface, the .onstartrequest(request, context) method
tells you when the request begins, while the .onstoprequest(request, context) method
tells you when the request ends.
... there are two parts: initializing the pump, and
telling it to asynchronously read data into the stream listener: var pump = components.classes["@mozilla.org/network/input-stream-pump;1"] .createinstance(components.interfaces.nsiinputstreampump); pump.init(stream, -1, -1, 0, 0, true); pump.asyncread(listener, context); nsipipe code examples file input and output for file input, see code snippets: reading from a file.
... * * also, baseinputstream has been comple
tely consumed at this point, so we * shouldn't read from it anymore.
Interfacing with the XPCOM cycle collector
handling jsobjects fields if your class needs to store a pointer to a jsobject then you need to
tell the cycle collector about it.
... when you have something in the js object pointer you need to use mozilla::holdjsobjects to
tell the gc to trace it and keep the object alive: ...
...unfortuna
tely this macro defines the trace method and so you can't list your js object; hence, you need to also manually implmenet trace and unlink as above.
...hence, we need to
tell the cycle collector about any such member variables.
IAccessibleTable
iscolumnselected() returns a boolean value indicating whether the specified column is comple
tely selected.
...isselected returns true if the specified column is selected comple
tely and false otherwise.
...isrowselected() returns a boolean value indicating whether the specified row is comple
tely selected.
...isselected returns true if the specified row is selected comple
tely and false otherwise.
IAccessibleTable2
iscolumnselected() returns a boolean value indicating whether the specified column is comple
tely selected.
...isselected returns true if the specified column is selected comple
tely and false otherwise.
...isrowselected() returns a boolean value indicating whether the specified row is comple
tely selected.
...isselected returns true if the specified row is selected comple
tely and false otherwise.
nsIDOMWindowUtils
sheets added via this api take effect immedia
tely on the document.
...if you don't need an absolu
tely up to date node list, you can set this to false.
...the removal takes effect immedia
tely.
...the displayport can approxima
tely be thought of as a "persistent" drawwindow() (albeit with coordinates relative to the css viewport): the bounds are remembered by the platform, and layer pixels are retained and updated inside the viewport bounds.
nsIWebNavigation
methods goback()
tells the object to navigate to the previous session history item.
... void goback( ); goforward()
tells the object to navigate to the next session history item.
... void goforward( ); gotoindex()
tells the object to navigate to the session history item at a given index.
... reload()
tells the object to reload the current page.
Working with windows in chrome code
note however, that the open() call returns before the window is fully loaded, so some calls, like win.document.ge
telementbyid() will fail.
...to access the elements and variables inside the sidebar, you need to use document.ge
telementbyid("sidebar").contentdocument or .contentwindow, like when accessing content documents.
... {status: "reading remote data", maxprogress: 50, progress: 10} ); progress.xul: <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <window onload="onload();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script><![cdata[ var gstatus, gprogressmeter; var maxprogress = 100; function onload() { gstatus = document.ge
telementbyid("status"); gprogressmeter = document.ge
telementbyid("progressmeter"); if("arguments" in window && window.arguments.length > 0) { maxprogress = window.arguments[0].maxprogress; setprogress(window.arguments[0].progress); setstatus(window.arguments[0].status); } } function setprogress(value) { gprogressmeter.value = 100 * value / maxprogress; } function setstatus(text...
...you could declare a local variable in each window along with corresponding setter functions to keep the "instances" of the variable in sync across windows, but fortuna
tely, there's a better way.
Mozilla
fortuna
tely, over the years, mozilla developers have come up with not just technologies and features to help you debug code, but have devised tips and techniques that can help too.
...a stacktrace will
tell mozilla developers what crashed and provide a starting point for investigating its cause.
...it is intended primarily for developers, and delibera
tely omits some topics that will be important in any redis deployment, like security and backups.
... zombie compartments this page
tells you how to detect and avoid zombie compartments, which are a particular kind of memory leak.
Plug-in Basics - Plugins
unlike a plug-in, a helper application runs separa
tely from the browser in its own application space and does not interact with the browser or the web.
... how plug-ins work the life cycle of a plug-in, unlike that of an application, is comple
tely controlled by the web page that calls it.
... var plugin = mimetype.enabledplugin; if (plugin) { // yes, so show the data in-line document.wri
teln("here\'s a movie: <object data='mymovie.swf' height='100' width='100'></object>"); } else { // no, so provide a link to the data document.wri
teln("<a href='mymovie.swf'>click here</a> to see a movie."); } } else { // no, so
tell them so document.wri
teln("sorry, can't show you this movie."); } overview of plug-in structure this section is an overview of basic informatio...
...this type of plug-in comple
tely fills the web page.
Streams - Plugins
in normal-mode streams, the browser calls the plug-in to
tell it when a stream is created and to push more data.
... receiving a stream sending a stream receiving a stream when the browser sends a data stream to the plug-in, it has several tasks to perform:
telling the plug-in when a stream is created
telling the plug-in when a stream is deleted finding out how much data the plug-in can accept writing the stream to the plug-in sending the stream in random-access mode sending the stream in file mode
telling the plug-in when a stream is created to
tell the plug-in instance when a new stream is created, the browser calls the npp_newstream method.
...
telling the plug-in when a stream is deleted the browser calls the npp_destroystream method when it completes the stream sent to the plug-in, either successfully or abnormally.
...this number
tells the browser that it can pass as much data to the instance as possible in a single call to npp_write.
Examine and edit HTML - Firefox Developer Tools
(paste) before paste the clipboard contents into the document immedia
tely before this node.
... (paste) after paste the clipboard contents into the document immedia
tely after this node.
... duplicate node create a copy of this element, and insert the copy immedia
tely after this element.
... editing html you can edit the html — tags, attributes, and content — directly in the html pane: double-click the text you want to edit, change it, and press enter to see the changes reflected immedia
tely.
Intensive JavaScript - Firefox Developer Tools
it gives us a compressed view of the waterfall, which
tells us what kinds of operations the browser is doing during the recording.
...we can see that frame rate is pretty healthy for most of the recording, but collapses comple
tely whenever we press the button.
... requestanimationframe()
tells the browser to run the given function in each frame, just before it performs a repaint.
... 0; i < iterations; i++) { var candidate = i * (multiplier * math.random()); var isprime = true; for (var c = 2; c <= math.sqrt(candidate); ++c) { if (candidate % c === 0) { // not prime isprime = false; break; } } if (isprime) { primes.push(candidate); } } return primes; } in the worker, we have to listen for a message
telling us to start, and send a "done" message back when we are done.
AbstractRange - Web APIs
in order to set a range endpoint within the text of an element, be sure to find the text node inside the element: let star
telem = document.queryselector("p"); let endelem = star
telem.queryselector("span"); let range = document.createrange(); range.setstart(star
telem, 0); range.setend(endelem, endelem.childnodes[0].length/2); let contents = range.clonecontents(); document.body.appendchild(contents); this example creates a new range, rng, and sets its starting point to the third child node of the first element whose c...
... to illustrate this, consider the html below: <div class="container"> <div class="header"> <img src="" class="si
telogo"> <h1>the ultimate website</h1> </div> <article> <section class="entry" id="entry1"> <h2>section 1: an interesting thing...</h2> <p>a <em>very</em> interesting thing happened on the way to the forum...</p> <aside class="callout"> <h2>aside</h2> <p>an interesting aside to share with you...</p> </aside> </section> </article> <pre id="lo...
... as it turns out, the dom specification fortuna
tely addresses this exact issue.
...the code to do that looks like the following: let paranode = document.queryselector("p"); let paratextnode = paranode.childnodes[1]; let range = document.createrange(); range.setstart(paratextnode, 6); range.setend(paratextnode, paratextnode.length-1); let fragment = range.clonecontents(); document.body.appendchild(fragment); first we get references to the paragraph node i
telf as well as to the second child node within the paragraph.
AuthenticatorAssertionResponse.authenticatorData - Web APIs
syntax var authnrdata = authenticatorassertionresponse.authenticatordata; value an arraybuffer that has a arraybuffer.by
telength of at least 37 bytes, containing the following fields: rpidhash (32 bytes) - a sha256 hash of the relying party id that was seen by the browser.
... bit 6, attested credential data (at) - if set, attestedcredentialdata will immedia
tely follow the first 37 bytes of this authenticatordata.
...extension data will follow attestedcredentialdata if it is present, or will immedia
telly follow the first 37 bytes of the authenticatordata if no attestedcredentialdata is present.
... credentialidlength (2 bytes) - the length of the credential id that immedia
tely follows these bytes.
CanvasRenderingContext2D.arcTo() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // tangential lines ctx.beginpath(); ctx.strokestyle = 'gray'; ctx.moveto(200, 20); ctx.lineto(200, 130); ctx.lineto(50, 20); ctx.stroke(); // arc ctx.beginpath(); ctx.strokestyle = 'black'; ctx.linewidth = 5; ctx.moveto(200, 20); ctx.arcto(200,130, 50,20, 40); ctx.stroke(); // start point ctx.beginpath(); ctx.fillstyle = 'blue'; ctx.arc...
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const p0 = { x: 230, y: 20 } const p1 = { x: 90, y: 130 } const p2 = { x: 20, y: 20 } const labelpoint = function (p) { const offset = 15; ctx.filltext('(' + p.x + ',' + p.y + ')', p.x + offset, p.y + offset); } ctx.beginpath(); ctx.moveto(p0.x, p0.y); ctx.arcto(p1.x, p1.y, p2.x, p2.y, 50); ctx.lineto(p2.x, p2.y); labelpoint(p0)...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(180, 90); ctx.arcto(180,130, 110,130, 130); ctx.lineto(110, 130); ctx.stroke(); result live demo more sophisticated demo of the method.
... html <div> <label for="radius">radius: </label> <input name="radius" type="range" id="radius" min=0 max=100 value=50> <label for="radius" id="radius-output">50</label> </div> <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const controlout = document.ge
telementbyid('radius-output'); const control = document.ge
telementbyid('radius'); control.oninput = () => { controlout.textcontent = r = control.value; }; const mouse = { x: 0, y: 0 }; let r = 100; // radius const p0 = { x: 0, y: 50 }; const p1 = { x: 100, y: 100 }; const p2 = { x: 150, y: 50 }; const p3 = { x: 200, y: 100 }; const labelpoint = function (p,...
Drawing text - Web APIs
function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); ctx.font = '48px serif'; ctx.filltext('hello world', 10, 50); } <canvas id="canvas" width="300" height="100"></canvas> draw(); a stroketext example the text is filled using the current strokestyle.
... function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); ctx.font = '48px serif'; ctx.stroketext('hello world', 10, 50); } <canvas id="canvas" width="300" height="100"></canvas> draw(); styling text in the examples above we are already making use of the font property to make the text a bit larger than the default size.
...le code <canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas> <div class="playable-buttons"> <input id="edit" type="button" value="edit" /> <input id="reset" type="button" value="reset" /> </div> <textarea id="code" class="playable-code"> ctx.font = "48px serif"; ctx.textbaseline = "hanging"; ctx.stroketext("hello world", 0, 100);</textarea> var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var edit = document.ge
telementbyid('edit'); var code = textarea.value; function drawcanvas() { ctx.clearrect(0, 0, canvas.width, canvas.height); eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; dra...
... function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); var text = ctx.measuretext('foo'); // textmetrics object text.width; // 16; } gecko-specific notes in gecko (the rendering engine of firefox, firefox os and other mozilla based applications), some prefixed apis were implemented in earlier versions to draw text on a canvas.
Pixel manipulation with canvas - Web APIs
<canvas id="canvas" width="300" height="227" style="float:left"></canvas> <div id="color" style="width:200px;height:50px;float:left"></div> var img = new image(); img.src = 'https://mdn.mozillademos.org/files/5397/rhino.jpg'; var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); img.onload = function() { ctx.drawimage(img, 0, 0); img.style.display = 'none'; }; var color = document.ge
telementbyid('color'); function pick(event) { var x = event.layerx; var y = event.layery; var pixel = ctx.getimagedata(x, y, 1, 1); var data = pixel.data; var rgba = 'rgba(' + data[0] + ', ' + data[1] + ', ' + d...
... <canvas id="canvas" width="300" height="227"></canvas> <div> <input id="grayscalebtn" value="grayscale" type="button"> <input id="invertbtn" value="invert" type="button"> </div> var img = new image(); img.src = 'https://mdn.mozillademos.org/files/5397/rhino.jpg'; img.onload = function() { draw(this); }; function draw(img) { var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.drawimage(img, 0, 0); img.style.display = 'none'; var imagedata = ctx.getimagedata(0, 0, canvas.width, canvas.height); var data = imagedata.data; var invert = function() { for (var i = 0; i < data.length; i += 4) { data[i] = 255 - data[i]; // red data[i + 1] = 255 - data[i + 1]; // green data[i +...
... 2] = 255 - data[i + 2]; // blue } ctx.putimagedata(imagedata, 0, 0); }; var grayscale = function() { for (var i = 0; i < data.length; i += 4) { var avg = (data[i] + data[i + 1] + data[i + 2]) / 3; data[i] = avg; // red data[i + 1] = avg; // green data[i + 2] = avg; // blue } ctx.putimagedata(imagedata, 0, 0); }; var invertbtn = document.ge
telementbyid('invertbtn'); invertbtn.addeventlistener('click', invert); var grayscalebtn = document.ge
telementbyid('grayscalebtn'); grayscalebtn.addeventlistener('click', grayscale); } zooming and anti-aliasing with the help of the drawimage() method, a second canvas and the imagesmoothingenabled property, we are able to zoom into our picture and see the details.
...ght="227"></canvas> <canvas id="zoom" width="300" height="227"></canvas> <div> <label for="smoothbtn"> <input type="checkbox" name="smoothbtn" checked="checked" id="smoothbtn"> enable image smoothing </label> </div> var img = new image(); img.src = 'https://mdn.mozillademos.org/files/5397/rhino.jpg'; img.onload = function() { draw(this); }; function draw(img) { var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.drawimage(img, 0, 0); img.style.display = 'none'; var zoomctx = document.ge
telementbyid('zoom').getcontext('2d'); var smoothbtn = document.ge
telementbyid('smoothbtn'); var togglesmoothing = function(event) { zoomctx.imagesmoothingenabled = this.checked; zoomctx.mozimagesmoothingenabled = this.checked; zoomctx.webk...
Document.execCommand() - Web APIs
crea
telink creates an hyperlink from the selection, but only if there is a selection.
... enableabsolutepositioneditor enables or disables the grabber that allows absolu
tely-positioned elements to be moved around.
... enableobjectresizing enables or disables the resize handles on images, tables, and absolu
tely-positioned elements and other resizable objects.
...the requirements for this string are the same as crea
telink.
EffectTiming.fill - Web APIs
note that authors are discouraged from using fill modes to persist the effect of an animation indefini
tely.
...in this case, we have just two keyframes; the first defines what affect is applied to the element immedia
tely after the animation first begins to play, and the second defines the effect applied to the element in the last moment before it ends.
... document.ge
telementbyid("animatebutton").addeventlistener("click", event => { document.ge
telementbyid("box").animate( boxrotationkeyframes, boxrotationtiming ); }, false); the rest of the code is pretty simple: it adds an event listener to the "animate" button so that when it's clicked by the user, the box is animated by calling element.animate() on it, providing the boxrotationkeyframes and boxrot...
...when used to persist the effect of an animation indefini
tely, however, they have a number of drawbacks: the forwards fill of an animation (or backwards fill if the animation is playing in reverse) will continue to override any changes to specified style indefini
tely which can lead to confusing behavior.
Element: fullscreenchange event - Web APIs
the fullscreenchange event is fired immedia
tely after an element switches into or out of full-screen mode.
... html <h1>fullscreenchange event example</h1> <div id="fullscreen-div"> <button id="toggle-fullscreen">toggle fullscreen mode</button> </div> javascript document.ge
telementbyid('fullscreen-div').addeventlistener('fullscreenchange', (event) => { // document.fullscreenelement will point to the element that // is in fullscreen mode if there is one.
... if (document.fullscreenelement) { console.log(`element: ${document.fullscreenelement.id} entered fullscreen mode.`); } else { console.log('leaving full-screen mode.'); } }); document.ge
telementbyid('toggle-fullscreen').addeventlistener('click', (event) => { if (document.fullscreenelement) { // exitfullscreen is only available on the document object.
... document.exitfullscreen(); } else { document.ge
telementbyid('fullscreen-div').requestfullscreen(); } }); specifications specification status fullscreen api living standard ...
Guide to the Fullscreen API - Web APIs
let's consider this <video> element: <video controls id="myvideo"> <source src="somevideo.webm"></source> <source src="somevideo.mp4"></source> </video> we can put that video into full-screen mode as follows: var elem = document.ge
telementbyid("myvideo"); if (elem.requestfullscreen) { elem.requestfullscreen(); } this code checks for the existence of the requestfullscreen() method before calling it.
... other information the document provides some additional information that can be useful when developing fullscreen web applications: documentorshadowroot.fullscreenelement the fullscreenelement property
tells you the element that's currently being displayed fullscreen.
... document.fullscreenenabled the fullscreenenabled property
tells you whether or not the document is currently in a state that would allow fullscreen mode to be requested.
... function togglefullscreen() { if (!document.fullscreenelement) { document.documen
telement.requestfullscreen(); } else { if (document.exitfullscreen) { document.exitfullscreen(); } } } this starts by looking at the value of the fullscreenelement attribute on the document (checking it prefixed with both moz, ms, or webkit).
Fullscreen API - Web APIs
returns a promise which is resolved once full-screen mode has been comple
tely shut off.
... documentorshadowroot.fullscreenelement the fullscreenelement property
tells you the element that's currently being displayed in full-screen mode on the dom (or shadow dom).
... document.fullscreenenabled the fullscreenenabled property
tells you whether or not it is possible to engage full-screen mode.
... function togglefullscreen() { if (!document.fullscreenelement) { document.documen
telement.requestfullscreen(); } else { if (document.exitfullscreen) { document.exitfullscreen(); } } } this starts by looking at the value of the document's fullscreenelement attribute.
Using the Gamepad API - Web APIs
var gamepadinfo = document.ge
telementbyid("gamepad-info"); var ball = document.ge
telementbyid("ball"); var start; var a = 0; var b = 0; next we use the gamepadconnected event to check for a gamepad being connected.
...in each execution of the loop we check if one of four buttons is being pressed; if so, we update the values of the a and b movement variables appropria
tely, then update the left and top properties, changing their values to the current values of a and b respectively.
... a.classname = "axes"; for (var i = 0; i < gamepad.axes.length; i++) { var p = document.createelement("progress"); p.classname = "axis"; //p.id = "a" + i; p.setattribute("max", "2"); p.setattribute("value", "1"); p.innerhtml = i; a.appendchild(p); } d.appendchild(a); // see https://github.com/luser/gamepadtest/blob/master/index.html var start = document.ge
telementbyid("start"); if (start) { start.style.display = "none"; } document.body.appendchild(d); requestanimationframe(updatestatus); } function disconnecthandler(e) { removegamepad(e.gamepad); } function removegamepad(gamepad) { var d = document.ge
telementbyid("controller" + gamepad.index); document.body.removechild(d); delete controllers[gamepad.index]; } function updatesta...
...tus() { if (!haveevents) { scangamepads(); } var i = 0; var j; for (j in controllers) { var controller = controllers[j]; var d = document.ge
telementbyid("controller" + j); var buttons = d.ge
telementsbyclassname("button"); for (i = 0; i < controller.buttons.length; i++) { var b = buttons[i]; var val = controller.buttons[i]; var pressed = val == 1.0; if (typeof(val) == "object") { pressed = val.pressed; val = val.value; } var pct = math.round(val * 100) + "%"; b.style.backgroundsize = pct + " " + pct; if (pressed) { b.classname = "button pressed"; } else { b.classname = "button"; } } var axes = d.ge
telementsbyclassname("axis"); for (i = 0; i < controller.ax...
Using microtasks in JavaScript with queueMicrotask() - Web APIs
while there have been tricks available that made it possible to enqueue microtasks in the past (such as by creating a promise that resolves immedia
tely), the addition of the queuemicrotask() method adds a standard way to introduce a microtask safely and without tricks.
... let logelem = document.ge
telementbyid("log"); let log = s => logelem.innerhtml += s + "<br>"; in the following code, we see a call to queuemicrotask() used to schedule a microtask to run.
... let logelem = document.ge
telementbyid("log"); let log = s => logelem.innerhtml += s + "<br>"; in the following code, we see a call to queuemicrotask() used to schedule a microtask to run.
... let logelem = document.ge
telementbyid("log"); let log = s => logelem.innerhtml += s + "<br>"; the main program code follows.
MediaStreamTrack.stop() - Web APIs
syntax track.stop() description calling stop()
tells the user agent that the track's source—whatever that source may be, including files, network streams, or a local camera or microphone—is no longer needed by the mediastreamtrack.
... since multiple tracks may use the same source (for example, if two tabs are using the device's microphone), the source itself isn't necessarily immedia
tely stopped.
...once no media tracks are using the source, the source may actually be comple
tely stopped.
... immedia
tely after calling stop(), the readystate property is set to ended.
Recording a media element - Web APIs
note that the autoplay attribute is used so that as soon as the stream starts to arrive from the camera, it immedia
tely gets displayed, and the muted attribute is specified to ensure that the sound from the user's microphone isn't output to their speakers, causing an ugly feedback loop.
...notice that the playback panel doesn't have autoplay set (so the playback doesn't start as soon as media arrives), and it has controls set, which
tells it to show the user controls to play, pause, and so forth.
... let preview = document.ge
telementbyid("preview"); let recording = document.ge
telementbyid("recording"); let startbutton = document.ge
telementbyid("startbutton"); let stopbutton = document.ge
telementbyid("stopbutton"); let downloadbutton = document.ge
telementbyid("downloadbutton"); let logelement = document.ge
telementbyid("log"); let recordingtimems = 5000; most of these are references to elements we need to work with.
...so by setting the download link's download attribute to "recordedvideo.webm", we
tell the browser that clicking the button should download a file named "recordedvideo.webm" whose contents are the recorded video.
Node.firstChild - Web APIs
<p id="para-01"> <span>first span</span> </p> <script> var p01 = document.ge
telementbyid('para-01'); console.log(p01.firstchild.nodename); </script> in the above, the console will show '#text' because a text node is inserted to maintain the whitespace between the end of the opening <p> and <span> tags.
... <p id="para-01"><span>first span</span></p> <script> var p01 = document.ge
telementbyid('para-01'); console.log(p01.firstchild.nodename); </script> now the console will show 'span'.
... to avoid the issue with node.firstchild returning #text or #comment nodes, parentnode.firs
telementchild can be used to return only the first element node.
... however, node.firs
telementchild requires a shim for internet explorer 9 and earlier.
Node.insertBefore() - Web APIs
example example 1 <div id="paren
telement"> <span id="childelement">foo bar</span> </div> <script> // create the new node to insert let newnode = document.createelement("span") // get a reference to the parent node let parentdiv = document.ge
telementbyid("childelement").parentnode // begin test case [ 1 ] : existing childelement (all works correctly) let sp2 = document.ge
telementbyid("childelement") parentdiv.insertbefore(newn...
... of id "childelement" parentdiv.insertbefore(newnode, sp2) // implicit dynamic cast to type node // end test case [ 2 ] // begin test case [ 3 ] : childelement is of type "undefined" ( string ) let sp2 = "undefined" // non-existent node of id "childelement" parentdiv.insertbefore(newnode, sp2) // generates "type error: invalid argument" // end test case [ 3 ] </script> example 2 <div id="paren
telement"> <span id="childelement">foo bar</span> </div> <script> // create a new, plain <span> element let sp1 = document.createelement("span") // get the reference element let sp2 = document.ge
telementbyid("childelement") // get the parent element let parentdiv = sp2.parentnode // insert the new element into before sp2 parentdiv.insertbefore(sp1, sp2) </script> note: there is no insertafter...
... in the previous example, sp1 could be inserted after sp2 using: parentdiv.insertbefore(sp1, sp2.nextsibling) if sp2 does not have a next sibling, then it must be the last child — sp2.nextsibling returns null, and sp1 is inserted at the end of the child node list (immedia
tely after sp2).
... // get the parent element let paren
telement = document.ge
telementbyid('paren
telement') // get the parent's first child let thefirstchild = paren
telement.firstchild // create a new element let newelement = document.createelement("div") // insert the new element before the first child paren
telement.insertbefore(newelement, thefirstchild) when the element does not have a first child, then firstchild is null.
Page Visibility API - Web APIs
for example, watching for blur and focus events on the window helps you know when your page is not the active page, but it does not
tell you that your page is actually hidden to the user.
... note: while onblur and onfocus will
tell you if the user switches windows, it doesn't necessarily mean it's hidden.
... policies in place to aid background page performance separa
tely from the page visibility api, user agents typically have a number of policies in place to mitigate the performance impact of background or hidden tabs.
... { // opera 12.10 and firefox 18 and later support hidden = "hidden"; visibilitychange = "visibilitychange"; } else if (typeof document.mshidden !== "undefined") { hidden = "mshidden"; visibilitychange = "msvisibilitychange"; } else if (typeof document.webkithidden !== "undefined") { hidden = "webkithidden"; visibilitychange = "webkitvisibilitychange"; } var videoelement = document.ge
telementbyid("videoelement"); // if the page is hidden, pause the video; // if the page is shown, play the video function handlevisibilitychange() { if (document[hidden]) { videoelement.pause(); } else { videoelement.play(); } } // warn if the browser doesn't support addeventlistener or the page visibility api if (typeof document.addeventlistener === "undefined" || hidden === undefine...
Using the Payment Request API - Web APIs
in the code above, you'll see that we've called the paymentresponse.complete() method to signal that the interaction has finished — you'd use this to carry out finishing steps, like updating the user interface to
tell the user the transaction is complete, etc.
... const checkoutbutton = document.ge
telementbyid('checkout-button'); if (window.paymentrequest) { let request = new paymentrequest(buildsupportedpaymentmethodnames(), buildshoppingcartdetails()); checkoutbutton.addeventlistener('click', function() { request.show().then(function(paymentresponse) { // handle successful payment }).catch(function(error) { // handle cancelled or failed payment.
... const checkoutbutton = document.ge
telementbyid('checkout-button'); checkoutbutton.innertext = "loading..."; if (window.paymentrequest) { let request = new paymentrequest(buildsupportedpaymentmethodnames(), buildshoppingcartdetails()); request.canmakepayment().then(function(canmakeafastpayment) { if (canmakeafastpayment) { checkoutbutton.innertext = "fast checkout with w3c"; } else { checkoutbutton.innert...
... const additionaldetailscontainer = document.ge
telementbyid('additional-details-container'); additionaldetailscontainer.style.display = 'block'; window.scrollto(additionaldetailscontainer.getboundingclientrect().x, 0); }).catch(function(error) { // handle error.
Pointer events - Web APIs
) { } function enter_handler(event) { } function down_handler(event) { } function move_handler(event) { } function up_handler(event) { } function cancel_handler(event) { } function out_handler(event) { } function leave_handler(event) { } function gotcapture_handler(event) { } function lostcapture_handler(event) { } function init() { var el=document.ge
telementbyid("target"); // register pointer event handlers el.onpointerover = over_handler; el.onpointerenter = enter_handler; el.onpointerdown = down_handler; el.onpointermove = move_handler; el.onpointerup = up_handler; el.onpointercancel = cancel_handler; el.onpointerout = out_handler; el.onpointerleave = leave_handler; el.gotpointercaptu...
... ev.pointertype + " is not suported"); } // call the tilt handler if (ev.tiltx != 0 && ev.tilty != 0) process_tilt(ev.tiltx, ev.tilty); // call the pressure handler process_pressure(ev.pressure); // if this event is not primary, call the non primary handler if (!ev.isprimary) process_non_primary(ev); } function init() { var el=document.ge
telementbyid("target"); // register pointerdown handler el.onpointerdown = down_handler; } </script> <body onload="init();"> <div id="target"> touch me ...
... <html> <script> function downhandler(ev) { let el = document.ge
telementbyid("target"); // element 'target' will receive/capture further events el.setpointercapture(ev.pointerid); } function init() { let el = document.ge
telementbyid("target"); el.onpointerdown = downhandler; } </script> <body onload="init();"> <div id="target"> touch me ...
... <html> <script> function downhandler(ev) { let el = document.ge
telementbyid("target"); // element "target" will receive/capture further events el.setpointercapture(ev.pointerid); } function cancelhandler(ev) { let el = document.ge
telementbyid("target"); // release the pointer capture el.releasepointercapture(ev.pointerid); } function init() { let el = document.ge
telementbyid("target"); // register pointerdown and pointercancel handlers el.onpointerdown = downhandler; el.onpointercancel = cancelhandler; ...
SVGTextPositioningElement - Web APIs
it is inherited by svgtex
telement, svgtspanelement, svgtrefelement and svgaltglyphelement.
...roke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggraphicselement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="89" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgtextconten
telement" target="_top"><rect x="51" y="65" width="210" height="50" fill="#fff" stroke="#d4dde4" stroke-width="2px" /><text x="156" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtextconten
telement</text></a><polyline points="51,89 41,84 41,94 51,89" stroke="#d4dde4" fill="none"/><line x1="41" y1="89" ...
...ll="#f4f7f8" stroke="#d4dde4" stroke-width="2px" /><text x="-114" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtextpositioningelement</text></a></svg></div> a:hover text { fill: #0095dd; pointer-events: all;} properties this interface also inherits properties from its parent, svgtextconten
telement.
... methods this interface doesn't provide any specific methods, but inherits methods from its parent, svgtextconten
telement.
WEBGL_compressed_texture_etc - Web APIs
the rgb part is encoded the same as rgb_etc2, but the alpha part is encoded separa
tely.
...the srgb part is encoded the same as srgb_etc2, but the alpha part is encoded separa
tely.
... ext.compressed_rgb8_punchthrough_alpha1_etc2 similar to rgb8_etc, but with ability to punch through the alpha channel, which means to make it comple
tely opaque or transparent.
... ext.compressed_srgb8_punchthrough_alpha1_etc2 similar to srgb8_etc, but with ability to punch through the alpha channel, which means to make it comple
tely opaque or transparent.
WebGLRenderingContext - Web APIs
to get an access to a webgl context for 2d and/or 3d graphics rendering, call getcontext() on a <canvas> element, supplying "webgl" as the argument: var canvas = document.ge
telementbyid('mycanvas'); var gl = canvas.getcontext('webgl'); once you have the webgl rendering context for a canvas, you can render within it.
... webglrenderingcontext.blendequationseparate() sets the rgb blend equation and alpha blend equation separa
tely.
... webglrenderingcontext.blendfuncseparate() defines which function is used for blending pixel arithmetic for rgb and alpha components separa
tely.
...does not seem to support html5 canvas.</canvas> <canvas>your browser does not seem to support html5 canvas.</canvas> body { text-align : center; } canvas { display : inline-block; width : 120px; height : 80px; margin : auto; padding : 0; border : none; background-color : black; } window.addeventlistener("load", function() { "use strict" var firstcanvas = document.ge
telementsbytagname("canvas")[0], secondcanvas = document.ge
telementsbytagname("canvas")[1]; firstcanvas.width = firstcanvas.clientwidth; firstcanvas.height = firstcanvas.clientheight; [firstcanvas, secondcanvas].foreach(function(canvas) { var gl = canvas.getcontext("webgl") || canvas.getcontext("experimental-webgl"); if (!gl) { document.queryselector("p").innerhtml = ...
Fundamentals of WebXR - Web APIs
fortuna
tely, webgl and the various webgl-based frameworks and libraries are available to make it much easier to deal with all of that.
... field of view and mixed reality devices to achieve a wide enough field of view that the user's eyes are tricked into believing that the virtual world comple
tely surrounds them, the fov needs to at least approach the width of the binocular vision area.
...when objects are drawn, they are drawn onto the goggles' lenses, either partially or comple
tely blocking the physical environment from being seen through the obscured portion of the lens.
... caves a cave automated virtual environment (cave) is an immersive vr environment in which the scene is projected or otherwise displayed on the walls (as well as possibly the ceiling and/or floor), thus comple
tely surrounding the user with the simulation and allowing them to be immersed in the scene.
Lighting a WebXR setting - Web APIs
fortuna
tely, lighting isn't overly difficult to apply in your own vertex and fragment shaders.
... in essence, lighting estimation collects this information about the light sources and the shape and orientation of the objects in the scene, along with information about the materials they're made of, then returns data you can use to create virtual light source objects that approxima
tely match the real world's lighting.
...by ensuring that the coordinates of the ar scene don't align with compass coordinates, and by reducing the precision of the sun's light angle, the location can no longer be accura
tely estimated using this technique.
...this could be done remo
tely, or it could be performed by an attacker who's located in the same room but wants to determine if the other person is also in the same room.
Migrating from webkitAudioContext - Web APIs
it was first implemented in webkit, and some of its older parts were not immedia
tely removed as they were replaced in the specification, leading to many sites using non-compatible code.
... new engines implementing the web audio spec (such as gecko) will only implement the official, final version of the specification, which means that code using webkitaudiocontext or old naming conventions in the web audio specification may not immedia
tely work out of the box in a compliant web audio implementation.
...r.responsetype = "arraybuffer"; xhr.send(); xhr.onload = function() { context.decodeaudiodata(xhr.response, function onsuccess(decodedbuffer) { // decoding was successful, do something useful with the audio buffer }, function onfailure() { alert("decoding the audio buffer failed"); }); }; note that the decodeaudiodata() method is asynchronous, which means that it will return immedia
tely, and then when the decoding finishes, one of the success or failure callback functions will get called depending on whether the audio decoding was successful.
... those values have since been changed to use the web idl based enumerated values, which should be familiar because they are similar to things like the the htmlinpu
telement property type.
Background audio processing using AudioWorklet - Web APIs
specifying a value of true as the result from your process() function in essence
tells the web audio api that your processor needs to keep being called even if the api doesn't think there's anything left for you to do.
... returning false from the process() method
tells the api that it should follow its normal logic and shut down your processor node if it deems it appropriate to do so.
... note: at this time, unfortuna
tely, chrome does not implement this algorithm in a manner that matches the current standard.
... here, for example, we set the value to newvalue, effective immedia
tely.
Using the Web Storage API - Web APIs
a different storage object is used for the sessionstorage and localstorage for each origin — they function and are controlled separa
tely.
...both of these can be manipulated in the same way, but separa
tely.
...for example: function setstyles() { var currentcolor = localstorage.getitem('bgcolor'); var currentfont = localstorage.getitem('font'); var currentimage = localstorage.getitem('image'); document.ge
telementbyid('bgcolor').value = currentcolor; document.ge
telementbyid('font').value = currentfont; document.ge
telementbyid('image').value = currentimage; htmlelem.style.backgroundcolor = '#' + currentcolor; pelem.style.fontfamily = currentfont; imgelem.setattribute('src', currentimage); } here, the first three lines grab the values from local storage.
... function populatestorage() { localstorage.setitem('bgcolor', document.ge
telementbyid('bgcolor').value); localstorage.setitem('font', document.ge
telementbyid('font').value); localstorage.setitem('image', document.ge
telementbyid('image').value); setstyles(); } the populatestorage() function sets three items in local storage — the background color, font, and image path.
Window.open() - Web APIs
note that remote urls won't load immedia
tely.
...moving and resizing a window remo
tely on the user's screen via script will very often annoy the users, will disorient the user, and will be wrong at best.
... how can i
tell when my window was blocked by a popup blocker?
... references "if your link spawns a new window, or causes another windows to 'pop up' on your display, or move the focus of the system to a new frame or window, then the nice thing to do is to
tell the user that something like that will happen." world wide web consortium accessibility initiative regarding popups "use link titles to provide users with a preview of where each link will take them, before they have clicked on it." ten good deeds in web design, jakob nielsen, october 1999 using link titles to help users predict where they are going, jakob nielsen, january 1998 exam...
Window.pageYOffset - Web APIs
mauris efficitur
tellus massa, id ullamcorper ipsum fermentum eu.
...integer euismod lectus a ipsum pellentesque lacinia.</p> `; document.ge
telementbyid("frame").contentdocument .body.innerhtml = contenthtml; in this example, an <iframe> is created and filled with content, then a specific element within the document is scrolled into view in the frame.
... <iframe id="frame"> </iframe> <div id="info"> </div> javascript var frame = document.ge
telementbyid("frame"); var framedoc = frame.contentdocument; var info = document.ge
telementbyid("info"); var target = framedoc.ge
telementbyid("overview"); framedoc.scrollingelement.scrolltop = target.offsettop; info.innertext = "y offset after scrolling: " + frame.contentwindow.pageyoffset + " pixels"; the javascript code begins by getting into frame and info the <iframe> element ...
...it then gets a reference to the element we want to scroll into view calling ge
telementbyid() on the frame's htmliframeelement.contentdocument.
WindowOrWorkerGlobalScope.setTimeout() - Web APIs
if this parameter is omitted, a value of 0 is used, meaning execute "immedia
tely", or more accura
tely, the next event cycle.
...function() { vcallback.apply(null, aargs); } : vcallback, ndelay); }; }, 0, 'test'); }()) ie-only fix if you want a comple
tely unobtrusive fix for every other mobile or desktop browser, including ie 9 and below, you can either use javascript conditional comments: /*@cc_on // conditional ie < 9 only fix @if (@_jscript_version <= 9) (function(f){ window.settimeout = f(window.settimeout); window.setinterval = f(window.setinterval); })(function(f){return function(c,t){var a=[].slice.call(arguments,2);retu...
...for example: function foo() { console.log('foo has been called'); } settimeout(foo, 0); console.log('after settimeout'); will write to the console: after settimeout foo has been called this is because even though settimeout was called with a delay of zero, it's placed on a queue and scheduled to run at the next opportunity; not immedia
tely.
...this causes an integer overflow when using delays larger than 2,147,483,647 ms (about 24.8 days), resulting in the timeout being executed immedia
tely.
Using the alert role - Accessibility
assistive technology products should listen for such an event and notify the user accordingly: screen readers may interrupt current output (whether it's speech or braille) and immedia
tely announce or display the alert message.
...if the element was already in the original source code when the page loaded, the screen reader will announce the error immedia
tely after announcing the page title.
...the pseudo code snippet below illustrates this approach: <p id="forminstruction">you must select at least 3 options</p> // when the user tries to submit the form with less than 3 checkboxes selected: document.ge
telementbyid("forminstruction").setattribute("role", "alert"); example 4: making an element with an alert role visible if an element already has role="alert" and is initially hidden using css, making it visible will cause the alert to fire as if it was just added to the page.
... .hidden { display:none; } <p id="expirationwarning" role="alert" class="hidden">your log in session will expire in 2 minutes</p> // removing the 'hidden' class makes the element visible, which will make the screen reader announce the alert: document.ge
telementbyid("expirationwarning").classname = ""; working examples: alert role example using an aria alert box alert example using a modal aria dialog box notes using the alert role on an element implies that element has aria-live="assertive".
ARIA: alert role - Accessibility
the alert role can be used to
tell the user an element has been dynamically updated.
... description one of the five live region roles, the alert role is used to provide the user with important, and usually time-sensitive, information, and often to
tell the user an element has been dynamically updated.
...it is perfect for situations such as when a user fills out a form and javascript is used to add an error message - the alert would immedia
tely read out the message.
... <button type="button" onclick="triggeralert">trigger alert</button> <p class="alert">the alert will trigger when the button is pressed.</p> function triggeralert() { var aler
tel = document.queryselector('.alert'); aler
tel.addattribute("role", "alert"); } accessibility concerns the alert role should read out content that has changed, or bring the user's attention to it immedia
tely, so it should not be used for static content or used regularly.
ARIA: application role - Accessibility
any sort of special interpretation of html structures and widgets should be suspended, and control should be comple
tely handed over to the browser and web application to handle mouse, keyboard, or touch interaction.
... in this mode, the web author is comple
tely responsible for handling any and all keyboard input, focus management, and other interactions and cannot assume assistive technologies would do any processing on their end.
... keyboard interactions keyboard interaction is comple
tely under the web author's control and can be anything associated with the particular widget being implemented.
... the application role does not have a related html widget and thus is comple
tely free form.
WAI-ARIA Roles - Accessibility
for a full list of roles, see using aria: roles, states, and properties aria: alert rolethe alert role can be used to
tell the user an element has been dynamically updated.
...dialogs can be either non-modal (it's still possible to interact with content outside of the dialog) or modal (only the content in the dialog can be interacted with).aria: document rolegenerally used in complex composite widgets or applications, the document role can inform assistive technologies to switch context to a reading mode: the document role
tells assistive technologies with reading or browse modes to use the document mode to read the content contained within this element.aria: feed rolea feed is a dynamic scrollable list of articles in which articles are added to or removed from either end of the list as the user scrolls.
... a feed enables screen readers to use the browse mode reading cursor to both read and scroll through a stream of rich content that may continue scrolling infini
tely by loading more content as the user reads.aria: figure rolethe aria figure role can be used to identify a figure inside page content where appropriate semantics do not already exist.
... alertdialog banner combobox command columnheader (es
telle) complementary composite definition directory feed gridcell (eric e) group input landmark link - old page listbox log - old page marquee math menu menubar menuitem menuitemcheckbox menuitemradio none note option presentation progressbar - old page radio - old page radiogroup range region roletype rowheader(es
telle) scrollbar searchbox section sectionhead sele...
Web applications and ARIA FAQ - Accessibility
unfortuna
tely, there isn't a more semantic tag available to developers in html 4, so we need to include aria roles and properties.
...var progressbar = document.ge
telementbyid("percent-loaded"); // set its aria roles and states, so that assistive technologies know what kind of widget it is.
...and here is the javascript code that will ensure the progress bar still works in older browsers: var progressbar = document.ge
telementbyid("progress-bar"); // check to see if the browser supports the html5 <progress> tag.
... document.ge
telementbyid("update-button").addeventlistener("click", function (e) { updateprogress(75); e.preventdefault(); }, false); } initdemo(); how do assistive technologies work?
Accessibility documentation index - Accessibility
20 using the aria-invalid attribute aria, accessibility, attribute, codingscripting, html, javascript, needscontent, role(2), agent, alert, user, useragent the aria-invalid attribute is used to indicate that the value entered into an input field does not conform to the format expected by the application.this may include formats such as email addresses or
telephone numbers.
... 51 aria: alert role aria, aria role, aria alert, aria widget, reference the alert role can be used to
tell the user an element has been dynamically updated.
... 60 aria: document role aria, aria role, document, reference generally used in complex composite widgets or applications, the document role can inform assistive technologies to switch context to a reading mode: the document role
tells assistive technologies with reading or browse modes to use the document mode to read the content contained within this element.
...a feed enables screen readers to use the browse mode reading cursor to both read and scroll through a stream of rich content that may continue scrolling infini
tely by loading more content as the user reads.
Using CSS transitions - CSS: Cascading Style Sheets
instead of having property changes take effect immedia
tely, you can cause the changes in a property to take place over a period of time.
... you can control the individual components of the transition with the following sub-properties: (note that these transitions loop infini
tely only for the purpose of our examples; css transitions only visualize a property change from start to finish.
... javascript examples care should be taken when using a transition immedia
tely after: adding the element to the dom using .appendchild() removing an element's display: none; property.
... <p>click anywhere to move the ball</p> <div id="foo"></div> using javascript you can make the effect of moving the ball to a certain position happen: var f = document.ge
telementbyid('foo'); document.addeventlistener('click', function(ev){ f.style.transform = 'translatey('+(ev.clienty-25)+'px)'; f.style.transform += 'translatex('+(ev.clientx-25)+'px)'; },false); with css you can make it smooth without any extra effort.
<filter-function> - CSS: Cascading Style Sheets
ight: 300px; background: url(https://media.prod.mdn.mozit.cloud/attachments/2020/07/29/17350/3b4892b7e820122ac6dd7678891d4507/firefox.png) no-repeat center; } li { display: flex; align-items: center; justify-content: center; margin-bottom: 20px; } input { width: 60% } output { width: 5%; text-align: center; } select { width: 40%; margin-left: 2px; } javascript const selec
telem = document.queryselector('select'); const divelem = document.queryselector('div'); const slider = document.queryselector('input'); const output = document.queryselector('output'); const curvalue = document.queryselector('p code'); selec
telem.addeventlistener('change', () => { setslider(selec
telem.value); setdiv(selec
telem.value); }); slider.addeventlistener('input', () => { setdiv(selec...
...
telem.value); }); function setslider(filter) { if(filter === 'blur') { slider.value = 0; slider.min = 0; slider.max = 30; slider.step = 1; slider.setattribute('data-unit', 'px'); } else if(filter === 'brightness' || filter === 'contrast' || filter === 'saturate') { slider.value = 1; slider.min = 0; slider.max = 4; slider.step = 0.05; slider.setattribute('data-unit', ''); } else if(filter === 'drop-shadow') { slider.value = 0; slider.min = -20; slider.max = 40; slider.step = 1; slider.setattribute('data-unit', 'px'); } else if(filter === 'opacity') { slider.value = 1; slider.min = 0; slider.max = 1; slider.step = 0.01; slider.setattribute('data-unit', ''); } else if(filter === 'grayscale' || filter === '...
...{ slider.value = 0; slider.min = 0; slider.max = 1; slider.step = 0.01; slider.setattribute('data-unit', ''); } else if(filter === 'hue-rotate') { slider.value = 0; slider.min = 0; slider.max = 360; slider.step = 1; slider.setattribute('data-unit', 'deg'); } } function setdiv(filter) { if(filter === 'drop-shadow') { divelem.style.filter = `${selec
telem.value}(${math.round(slider.value)}${slider.getattribute('data-unit')} ${math.round(slider.value)}${slider.getattribute('data-unit')} ${math.round(math.abs(slider.value/2))}${slider.getattribute('data-unit')})`; } else { divelem.style.filter = `${selec
telem.value}(${slider.value}${slider.getattribute('data-unit')}`; } updateoutput(); updatecurvalue(); } function updateoutput() { ...
...output.textcontent = slider.value; } function updatecurvalue() { curvalue.textcontent = `filter: ${divelem.style.filter}`; } setslider(selec
telem.value); setdiv(selec
telem.value); result specifications specification status filter effects module level 1the definition of 'filter-function' in that specification.
justify-self - CSS: Cascading Style Sheets
for absolu
tely-positioned elements, it aligns an item inside its containing block on the inline axis, accounting for the offset values of top, left, bottom, and right.
... values auto the value used is the value of the justify-items property of the parents box, unless the box has no parent, or is absolu
tely positioned, in these cases, auto represents normal.
... in absolu
tely-positioned layouts, the keyword behaves like start on replaced absolu
tely-positioned boxes, and as stretch on all other absolu
tely-positioned boxes.
... formal definition initial valueautoapplies toblock-level boxes, absolu
tely-positioned boxes, and grid itemsinheritednocomputed valueas specifiedanimation typediscrete formal syntax auto | normal | stretch | <baseline-position> | <overflow-position>?
Making content editable - Developer guides
these are object resizing on <img>, <table>, and absolu
tely-positioned elements; inline table editing to add or remove rows and columns; and the grabber that allows moving of absolu
tely-positioned elements.
... fortuna
tely, in modern browsers things are somewhat more consistent.
...oard.sites", "https://www.mozilla.org"); user_pref("capability.policy.allowclipboard.clipboard.cutcopy", "allaccess"); user_pref("capability.policy.allowclipboard.clipboard.paste", "allaccess"); example: a simple but complete rich text editor <!doctype html> <html> <head> <title>rich text editor</title> <script type="text/javascript"> var odoc, sdeftxt; function initdoc() { odoc = document.ge
telementbyid("textbox"); sdeftxt = odoc.innerhtml; if (document.compform.switchmode.checked) { setdocmode(true); } } function formatdoc(scmd, svalue) { if (validatemode()) { document.execcommand(scmd, false, svalue); odoc.focus(); } } function validatemode() { if (!document.compform.switchmode.checked) { return true ; } alert("uncheck \"show html\"."); odoc.focus(); return false; } f...
...ick="formatdoc('indent');" src="data:image/gif;base64,r0lgodlhfgawaomiaaaaadljwl9vj1ie35gjuaezxtdv3nha7p///////////////////////////////yh5baeaaagalaaaaaawabyaaaq7emljq704650b/x8gemmpgugwhjnzxodkso5oquogo5khbwwesymqscrdhu9voyk5tm9zspfsr9gsjwiaow==" /> <img class="intlink" title="hyperlink" onclick="var slnk=prompt('write the url here','http:\/\/');if(slnk&&slnk!=''&&slnk!='http://'){formatdoc('crea
telink',slnk)}" src="data:image/gif;base64,r0lgodlhfgawaomkab1chdrly19vj3morpgjuaezxrcztb/i19ha7pv8/f///////////////////////yh5baekaa8alaaaaaawabyaaary8mljq7046827/2byiqvhhg9pegvgiklydeuby/rle4fqf4dcj2aqxaijqdcwqcaebwiioemqbgsafhdagghgi9xghahmnoszgjkjei33uesv2+/4vd4taqa7" /> <img class="intlink" title="cut" onclick="formatdoc('cut');" src="data:image/gif;base64,r0lgodlhfgawaiqsab1chbfnsrjtysjywjljwkx...
HTML5 Parser - Developer guides
are not valid javascript escapes; the character code strategy is more general-purpose.) inline svg and mathml support as a comple
tely new parsing feature, html5 introduced support for inline svg and mathml in text/html.
... the syntax <foo/> opens and immedia
tely closes the foo element if it is a mathml or svg element (i.e.
... attributes starting with xmlns have absolu
tely no effect on what namespace elements or attributes end up in, so you don’t need to use attributes starting with xmlns.
... to deal with legacy pages where authors have pasted partial svg fragments into html (who knows why) or used a <math> tag for non-mathml purposes, attempts to nest various common html elements as children of svg elements (without foreignobject) will immedia
tely break out of svg or mathml context.
Parsing and serializing XML - Developer guides
parsing strings into dom trees this example converts an xml fragment in a string into a dom tree using a domparser: var smystring = '<a id="a"><b id="b">hey!</b></a>'; var oparser = new domparser(); var odom = oparser.parsefromstring(smystring, "application/xml"); // print the name of the root element or error message console.log(odom.documen
telement.nodename == "parsererror" ?
... "error while parsing" : odom.documen
telement.nodename); parsing url-addressable resources into dom trees using xmlhttprequest here is sample code that reads and parses a url-addressable xml file into a dom tree: var xhr = new xmlhttprequest(); xhr.onload = function() { dump(xhr.responsexml.documen
telement.nodename); } xhr.onerror = function() { dump("error while getting xml."); } xhr.open("get", "example.xml"); xhr.responsetype = "document"; xhr.send(); the value returned in the xhr object's responsexml field is a document constructed by parsing the xml.
... var dochtml = document.documen
telement.innerhtml; as a result, dochtml is a domstring containing the html of the contents of the document; that is, the <body> element's contents.
... you can get html corresponding to the <body> and its descendants with this code: var dochtml = document.documen
telement.outerhtml; ...
<input type="datetime-local"> - HTML: Hypertext Markup Language
you can also get and set the date value in javascript using the htmlinpu
telement.value property, for example: var datecontrol = document.queryselector('input[type="datetime-local"]'); datecontrol.value = '2017-06-01t08:30'; there are several methods provided by javascript's date that can be used to convert numeric date information into a properly-formatted string, or you can do it manually.
... </select> in either case, the date/time and time zone values would be submitted to the server as separate data points, and then you'd need to store them appropria
tely in the database on the server-side.
...if you are stuck with other hardware, you can try to emulate 64-bit hardware inside a 32-bit virtual machine, but most vms don't support this kind of virtualization, stability may suffer, and performance will defina
tely suffer greatly.
...ter { position: absolute; content: '✖'; padding-left: 5px; } input:valid+span:after { position: absolute; content: '✓'; padding-left: 5px; } the other part of the code that may be of interest is the feature detection code — to detect whether the browser supports <input type="datetime-local">, we create a new <input> element, try setting its type to datetime-local, then immedia
tely check what its type is set to.
<input type="email"> - HTML: Hypertext Markup Language
if the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored comple
tely.
...its value can, however, still be changed by javascript code directly setting the htmlinpu
telement.value property.
...it only specifies approxima
tely how many can be seen at a time.
... it's far too easy for someone to make adjustments to the html that allow them to bypass the validation, or to remove it comple
tely.
<script>: The Script element - HTML: Hypertext Markup Language
implicit aria role no corresponding role permitted aria roles no role permitted dom interface htmlscrip
telement attributes this element includes the global attributes.
... nonce a cryptographic nonce (number used once) to whi
telist scripts in a script-src content-security-policy.
... notes scripts without async , defer or type="module" attributes, as well as inline scripts, are fetched and executed immedia
tely, before the browser continues to parse the page.
... <!-- generated by the server --> <script id="data" type="application/json">{"userid":1234,"username":"john doe","membersince":"2000-01-01t00:00:00.000z"}</script> <!-- static --> <script> const userinfo = json.parse(document.ge
telementbyid("data").text); console.log("user information: %o", userinfo); </script> specifications specification status comments html living standardthe definition of '<script>' in that specification.
HTTP Public Key Pinning (HPKP) - HTTP
http public key pinning (hpkp) was a security feature that used to
tell a web client to associate a specific cryptographic public key with a certain web server to decrease the risk of mitm attacks with forged certificates.
...hpkp can circumvent this threat for the https protocol by
telling the client which public key belongs to a certain web server.
...the first time a web server
tells a client via a special http header which public keys belong to it, the client stores this information for a given period of time.
...max-age=5184000
tells the client to store this information for two months, which is a reasonable time limit according to the ietf rfc.
Using Promises - JavaScript
to avoid having them cluttering up your output—by adding a handler for the unhandledrejection event, like this: window.addeventlistener("unhandledrejection", event => { /* you might start here by adding code to examine the promise specified by event.promise and the reason in event.reason */ event.preventdefault(); }, false); by calling the event's preventdefault() method, you
tell the javascript runtime not to do its default action when rejected promises go unhandled.
...unfortuna
tely, some apis still expect success and/or failure callbacks to be passed in the old way.
...result3) */ timing to avoid surprises, functions passed to then() will never be called synchronously, even with an already-resolved promise: promise.resolve().then(() => console.log(2)); console.log(1); // 1, 2 instead of running immedia
tely, the passed-in function is put on a microtask queue, which means it runs later when the queue is emptied at the end of the current run of the javascript event loop, i.e.
... a good rule-of-thumb is to always either return or terminate promise chains, and as soon as you get a new promise, return it immedia
tely, to flatten things: dosomething() .then(function(result) { return dosomethingelse(result); }) .then(newresult => dothirdthing(newresult)) .then(() => dofourththing()) .catch(error => console.error(error)); note that () => x is short for () => { return x; }.
DataView() constructor - JavaScript
syntax new dataview(buffer [, byteoffset [, by
telength]]) parameters buffer an existing arraybuffer or sharedarraybuffer to use as the storage backing the new dataview object.
... by
telength optional the number of elements in the byte array.
... exceptions rangeerror thrown if the byteoffset or by
telength parameter values result in the view extending past the end of the buffer.
... for example, if the buffer is 16 bytes long, the byteoffset is 8, and the by
telength is 10, this error is thrown because the resulting view tries to extend 2 bytes past the total length of the buffer.
Promise - JavaScript
this lets asynchronous methods return values like synchronous methods: instead of immedia
tely returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.
...sometimes there is no choice, because an error must be handled immedia
tely.
... "use strict"; var promisecount = 0; function testpromise() { let thispromisecount = ++promisecount; let log = document.ge
telementbyid('log'); // begin log.insertadjacenthtml('beforeend', thispromisecount + ') started (sync code started)'); // we make a new promise: we promise a numeric count of this promise, starting from 1 (after waiting 3s) let p1 = new promise((resolve, reject) => { // the executor function is called with the ability to resolve or reject the promise log.insertadjacenthtml('beforeend'...
...ulfillment value log.insertadjacenthtml('beforeend', val + ') promise fulfilled (async code terminated)'); }).catch((reason) => { // log the rejection reason console.log(`handle rejected promise (${reason}) here.`); }); // end log.insertadjacenthtml('beforeend', thispromisecount + ') promise made (sync code terminated)'); } if ("promise" in window) { let btn = document.ge
telementbyid("btn"); btn.addeventlistener("click",testpromise); } else { log = document.ge
telementbyid('log'); log.innerhtml = "live example not available as your browser doesn't support the <code>promise<code> interface."; } this example is started by clicking the button.
Using templates and slots - Web Components
let's look at a trivial quick example: <template id="my-paragraph"> <p>my paragraph</p> </template> this won't appear in your page until you grab a reference to it with javascript and then append it to the dom, using something like the following: let template = document.ge
telementbyid('my-paragraph'); let templatecontent = template.content; document.body.appendchild(templatecontent); although trivial, you can already start to see how this could be useful.
...we'll call it <my-paragraph>: customelements.define('my-paragraph', class extends htmlelement { constructor() { super(); let template = document.ge
telementbyid('my-paragraph'); let templatecontent = template.content; const shadowroot = this.attachshadow({mode: 'open'}) .appendchild(templatecontent.clonenode(true)); } } ); the key point to note here is that we append a clone of the template content to the shadow root, created using the node.clonenode() method.
... customelements.define('element-details', class extends htmlelement { constructor() { super(); const template = document .ge
telementbyid('element-details-template') .content; const shadowroot = this.attachshadow({mode: 'open'}) .appendchild(template.clonenode(true)); } } ); using the <element-details> custom element with named slots now let’s take that <element-details> element and actually use it in our document: <element-details> <span slot="element-name">slot</span> <span slot="des...
...hanism for holding client- side content that is not to be rendered when a page is loaded but may subsequently be instantiated during runtime using javascript.</span> </element-details> <script> customelements.define('element-details', class extends htmlelement { constructor() { super(); const template = document .ge
telementbyid('element-details-template') .content; const shadowroot = this.attachshadow({mode: 'open'}) .appendchild(template.clonenode(true)); } }) </script> </body> </html> ...
Introduction to using XPath in JavaScript - XPath
contextnode.documen
telement : contextnode.ownerdocument.documen
telement ); or alternatively by using the <code>creatensresolver</code> method of a <code>xpathevaluator</code> object.
...contextnode.documen
telement : contextnode.ownerdocument.documen
telement ); </pre> and then pass document.evaluate, the nsresolver variable as the namespaceresolver parameter.
...xmldoc.documen
telement : xmldoc.ownerdocument.documen
telement); var personiterator = xmldoc.evaluate('//person', xmldoc, nsresolver, xpathresult.any_type, null ); note when the xpathresult object is not defined, the constants can be retrieved in privileged code using components.interfaces.nsidomxpathresult.any_type (ci.nsidomxpathresult).
... in order to accura
tely grab elements with the xlink @href attribute (without also being confined to predefined prefixes in a namespace resolver), one could obtain them as follows: var xpathels = 'someelements[@*[local-name() = "href" and namespace-uri() = "http://www.w3.org/1999/xlink"]]'; // grabs elements with any single attribute that has both the local name 'href' and the xlink namespace var thislevel = xml.evalu...
Compiling from Rust to WebAssembly - WebAssembly
in this case, that statement is an extern, which
tells rust that we want to call some externally defined functions.
...the first part — [lib] —
tells rust to build a cdylib version of our package; we won't get into what that means in this tutorial.
...here's where we
tell cargo what version of wasm-bindgen we want to depend on; in this case, that's any 0.2.z version (but not 0.3.0 or above).
...as far as the javascript code can
tell, this is just a normal module.
Using the WebAssembly JavaScript API - WebAssembly
these methods are easier than their non-streaming counterparts, because they can turn the byte code directly into module/instance instances, cutting out the need to separa
tely put the response into an arraybuffer.
... note: since an arraybuffer’s by
telength is immutable, after a successful memory.prototype.grow() operation the buffer getter will return a new arraybuffer object (with the new by
telength) and any previous arraybuffer objects become “detached”, or disconnected from the underlying memory they previously pointed to.
... the mutations are immedia
tely accessible via table.prototype.get() in javascript, and to wasm modules.
... const output = document.ge
telementbyid('output'); function asserteq(msg, got, expected) { output.innerhtml += `testing ${msg}: `; if (got !== expected) output.innerhtml += `fail!<br>got: ${got}<br>expected: ${expected}<br>`; else output.innerhtml += `success!
Communicating With Other Scripts - Archive of obsolete content
ncludes a button and a page script: <html> <head> <meta charset="utf-8"> </head> <body> <input id="message" type="button" value="send a message"/> <script type="text/javascript" src="page-script.js"></script> </body> </html> the content script "content-script.js" adds an event listener to the button, that sends a custom event containing a message: var messenger = document.ge
telementbyid("message"); messenger.addeventlistener("click", sendcustomevent, false); function sendcustomevent() { var greeting = {"greeting" : "hello world"}; var event = document.createevent('customevent'); event.initcustomevent("addon-message", true, true, greeting); document.documen
telement.dispatchevent(event); } finally, the page script "page-script.js" listens for the message and log...
...from firefox 30 this sharing requires an extra step: the content script needs to explicitly clone the message payload into the page script's scope using the global cloneinto() function: var messenger = document.ge
telementbyid("message"); messenger.addeventlistener("click", sendcustomevent, false); function sendcustomevent() { var greeting = {"greeting" : "hello world"}; var cloned = cloneinto(greeting, document.defaultview); var event = document.createevent('customevent'); event.initcustomevent("addon-message", true, true, cloned); document.documen
telement.dispatchevent(event); } messaging from pa...
....js") }); the web page "talk.html" creates and dispatches a custom dom event, using initcustomevent()'s detail parameter to supply the payload: <!doctype html> <html> <head></head> <body> <script> function sendmessage() { var event = document.createevent('customevent'); event.initcustomevent("addon-message", true, true, { hello: 'world' }); document.documen
telement.dispatchevent(event); } </script> <button onclick="sendmessage()">send message</button> </body> </html> finally, the content script "listen.js" listens for the new event and retrieves the payload from its detail attribute: window.addeventlistener("addon-message", function(event) { console.log(json.stringify(event.detail)); }, false); ...
Communicating using "port" - Archive of obsolete content
accessing port accessing port in the content script note that the global self object is comple
tely different from the self module, which provides an api for an add-on to access its data files and id.
... function getfirstparagraph() { var paras = document.ge
telementsbytagname('p'); console.log(paras[0].textcontent); self.port.removelistener("get-first-para", getfirstparagraph); } self.port.on("get-first-para", getfirstparagraph); the result is that the paragraph is only logged the first time the button is clicked.
... this example rewrites the "listener.js" content script in the port.removelistener() example so that it uses once(): function getfirstparagraph() { var paras = document.ge
telementsbytagname('p'); console.log(paras[0].textcontent); } self.port.once("get-first-para", getfirstparagraph); json-serializable values the payload for an message can be any json-serializable value.
Content Scripts - Archive of obsolete content
it takes one of: "start": load the scripts immedia
tely after the document element for the page is inserted into the dom.
...so to emit a message from a content script: self.port.emit("mycontentscriptmessage", mycontentscriptmessagepayload); to receive a message from the add-on code: self.port.on("myaddonmessage", function(myaddonmessagepayload) { // handle the message }); note that the global self object is comple
tely different from the self module, which provides an api for an add-on to access its data files and id.
... = require("sdk/page-worker").page({ contentscriptfile: self.data.url("content-script.js"), contenturl: "http://en.wikipedia.org/wiki/internet" }); pageworker.port.on("first-para", function(firstpara) { console.log(firstpara); }); pageworker.port.emit("get-first-para"); // content-script.js self.port.on("get-first-para", getfirstpara); function getfirstpara() { var paras = document.ge
telementsbytagname("p"); if (paras.length > 0) { var firstpara = paras[0].textcontent; self.port.emit("first-para", firstpara); } } from page-mod a single page-mod object might attach its scripts to multiple pages, each with its own context in which the content scripts are executing, so it needs a separate channel (worker) for each page.
Classes and Inheritance - Archive of obsolete content
to illustrate this, let's define a simple constructor for a class shape: function shape(x, y) { this.x = x; this.y = y; } we can now use this constructor to create instances of shape: let shape = new shape(2, 3); shape instanceof shape; // => true shape.x; // => 2 shape.y; // => 3 the keyword new
tells javascript that we are performing a constructor call.
...the method draw is defined on instances of shape, so we defini
tely want it to be defined on instances of circle.
...consider the following: let circle = circle(2, 3, 5); circle instanceof shape; // => false since instances of circle inherit from shape, we defini
tely want the result of this expression to be true.
Modules - Archive of obsolete content
unfortuna
tely, javascript does not yet have native support for modules: it has to rely on the host application to provide it with functionality such as loading subscripts, and exporting/ importing names.
...unfortuna
tely, javascript does not provide any means to load scripts from other locations: we have to rely on the host application to provide us with this functionality.
...a whi
telist of modules is generated statically when the add-on is linked.
dev/panel - Archive of obsolete content
panel.html", onready: function() { this.postmessage("message from the add-on"); } }); // export the constructor exports.mypanel = mypanel; // create a new tool, initialized // with the new constructor const mytool = new tool({ panels: { mypanel: mypanel } }); in the panel document script: // my-panel.js window.addeventlistener("message", function(event) { var content = document.ge
telementbyid("content"); content.textcontent = event.data; }); note that at the moment you have to pass an array of ports into postmessage, even if you don't need to use them: // main.js // require the sdk modules const { panel } = require("dev/panel"); const { tool } = require("dev/toolbox"); const { class } = require("sdk/core/heritage"); const mypanel = class({ extends: panel, label: "m...
..., dispose: function() { this.debuggee = null; }, onready: function() { this.debuggee.start(); this.postmessage("port", [this.debuggee]); } }); // export the constructor exports.mypanel = mypanel; // create a new tool, initialized // with the new constructor const mytool = new tool({ panels: { mypanel: mypanel } }); in my-panel.js: // my-panel.js var content = document.ge
telementbyid("content"); window.addeventlistener("message", function(event) { var debuggee = event.ports[0]; console.log(debuggee); debuggee.onmessage = function(event) { content.textcontent = json.stringify(event.data); } debuggee.postmessage({ "to":"root", "type":"listtabs" }); }); if you do this, don't forget to call start() on the port before passing it over to the pa...
...ke this: <html> <head> <meta charset="utf-8"> <link href="./my-panel.css"rel="stylesheet"></link> <script src="resource://sdk/dev/volcan.js"></script> </head> <body> <div id = "content"></div> </body> <script src="./my-panel.js"></script> </html> here's a script that uses volcan.js to get the selected tab and display its url: // my-panel.js var content = document.ge
telementbyid("content"); window.addeventlistener("message", function(event) { var debuggee = event.ports[0]; volcan.connect(debuggee).
Creating Reusable Modules - Archive of obsolete content
.createinstance(ci.nsilocalfile); f.initwithpath(path); var istream = cc["@mozilla.org/network/file-input-stream;1"] .createinstance(ci.nsifileinputstream); // open for reading istream.init(f, 0x01, 0444, 0); var ch = cc["@mozilla.org/security/hash;1"] .createinstance(ci.nsicryptohash); // we want to use the md5 algorithm ch.init(ch.md5); // this
tells updatefromstream to read the entire file const pr_uint32_max = 0xffffffff; ch.updatefromstream(istream, pr_uint32_max); // pass false here to get binary data back var hash = ch.finish(false); // convert the binary hash data to a hex string.
... .createinstance(ci.nsilocalfile); f.initwithpath(path); var istream = cc["@mozilla.org/network/file-input-stream;1"] .createinstance(ci.nsifileinputstream); // open for reading istream.init(f, 0x01, 0444, 0); var ch = cc["@mozilla.org/security/hash;1"] .createinstance(ci.nsicryptohash); // we want to use the md5 algorithm ch.init(ch.md5); // this
tells updatefromstream to read the entire file const pr_uint32_max = 0xffffffff; ch.updatefromstream(istream, pr_uint32_max); // pass false here to get binary data back var hash = ch.finish(false); // convert the binary hash data to a hex string.
... .createinstance(ci.nsilocalfile); f.initwithpath(path); var istream = cc["@mozilla.org/network/file-input-stream;1"] .createinstance(ci.nsifileinputstream); // open for reading istream.init(f, 0x01, 0444, 0); var ch = cc["@mozilla.org/security/hash;1"] .createinstance(ci.nsicryptohash); // we want to use the md5 algorithm ch.init(ch.md5); // this
tells updatefromstream to read the entire file const pr_uint32_max = 0xffffffff; ch.updatefromstream(istream, pr_uint32_max); // pass false here to get binary data back var hash = ch.finish(false); // convert the binary hash data to a hex string.
Dialogs and Prompts - Archive of obsolete content
programmatic button access if you want to access the accept ("ok") and cancel buttons from script, use this: // disable the ok and cancel btns document.documen
telement.getbutton("accept").disabled = true; document.documen
telement.getbutton("cancel").disabled = true; links dialog.xml — xbl bindings for <dialog> and <dialogheader> elements.
...><label value="name:"/><textbox id="name"/></row> <row align="center"><label value="description:"/><textbox id="description"/></row> <row align="center"><spacer/><checkbox id="enabled" label="check to enable"/></row> </rows> </grid> </dialog> mydialog.js: // called once when the dialog displays function onload() { // use the arguments passed to us by the caller document.ge
telementbyid("name").value = window.arguments[0].inn.name; document.ge
telementbyid("description").value = window.arguments[0].inn.description; document.ge
telementbyid("enabled").checked = window.arguments[0].inn.enabled; } // called once if and only if the user clicks ok function onok() { // return the changed arguments.
... // notice if user clicks cancel, window.arguments[0].out remains null // because this function is never called window.arguments[0].out = {name:document.ge
telementbyid("name").value, description:document.ge
telementbyid("description").value, enabled:document.ge
telementbyid("enabled").checked}; return true; } see also passing parameter to a dialog and getting return values from it.
Installing Extensions and Themes From Web Pages - Archive of obsolete content
furthermore, calling updateenabled may lead to problems if your distribution site is not in the user's whi
telist, because firefox only displays the "installation blocked" message when install or installchrome are called, or when a xpi file is loaded.
...and your site is not in the whi
telist, when the user invokes that code, updateenabled will return false because your site isn't whi
telisted, and since it was updateenabled that discovered this, not a call to install, there will be no notification to the user.
... thus you should only use updateenabled to display content in the page to alert the user that software installation is disabled, or your site is not in the whi
telist—do not place it in the install code path.
Chapter 5: Let's build a Firefox extension - Archive of obsolete content
ad="initclock();"> <script type="application/javascript" src="chrome://helloworld/content/clock.js"/> <hbox align="center"> <label value="current time:" /> <textbox id="currenttime" /> </hbox> </dialog> listing 6: content for clock.js function initclock() { showcurrenttime(); window.setinterval(showcurrenttime, 1000); } function showcurrenttime() { var textbox = document.ge
telementbyid("currenttime"); textbox.value = new date().tolocaletimestring(); textbox.select(); } operations check perform an operations check to make sure that your changes to the source file are correct.
...download the files icon.png and icon-small.png from the resources website and place them appropria
tely.
...if true, causes a confirmation dialog to appear; if false, deletes immedia
tely.
Appendix B: Install and Uninstall Scripts - Archive of obsolete content
in this case the user is told that firefox needs to restart in order for the extension to be comple
tely removed.
...the add-on will not be comple
tely removed until the browser is restarted.
...you shouldn't perform very time-consuming operations here, at least not without
telling users what is going on.
Appendix F: Monitoring DOM changes - Archive of obsolete content
unfortuna
tely, adding listeners for any of these events to a document has a highly deleterious effect on performance, an effect which is not mitigated in the slightest by later removing those listeners.
... non-mutation triggers it is usually possible to
tell when a mutation has occurred or is about to occur without resorting to mutation events or observers.
... ' + watchnodes.namespace + prop) .join('\n'); doc.addeventlistener('animationstart', listener, false); function listener(event) { if (event.animationname == event) callback.call(this, event); } style.textcontent = ' ' + preamble + selector + '{' + properties + '}'; (doc.head || doc.documen
telement).appendchild(style); // this will only work in chrome privileged code.
Getting Started with Firefox Extensions - Archive of obsolete content
they can add anything from a toolbar button to a comple
tely new feature.
... firefox provides a very rich and flexible architecture that allows extension developers to add advanced features, customize the user's experience, and comple
tely replace and remove parts of the browser.
...you should see another pop-up
telling you that you are installing an unverified add-on.
The Box Model - Archive of obsolete content
in order to use this page, you'll need to install the remote xul manager extension and add developer.mozilla.org to the whi
telist.
...using the former allows the ui to scale proportiona
tely depending on font size settings, which are often changed by users with accessibility limitations.
...a spacer element is comple
tely invisible and doesn't do more than take space.
Creating a status bar extension - Archive of obsolete content
many of the concepts introduced here apply to any xul-based application; however, to keep from getting comple
tely overwhelmed, we're going to focus specifically on firefox.
...download the sample the install manifest the install manifest, install.rdf, is a text file containing information that
tells the host application important information about the extension.
...the chrome manifest the chrome manifest is a file that
tells the target application where to look for the chrome package for your extension.
Using XML Data Islands in Mozilla - Archive of obsolete content
like this: <script id="purchase-order" type="application/xml"> <purchaseorder xmlns="http://example.mozilla.org/purchaseorderml"> <lineitem> <name>line item 1</name> <price>1.25</price> </lineitem> <lineitem> <name>line item 2</name> <price>2.48</price> </lineitem> </purchaseorder> </script> the xml source text can then be retrieved like this: var ordersource = document.ge
telementbyid("purchase-order").textcontent; the xml source text can be parsed into a dom tree using the domparser api: var parser = new domparser(); var doc = parser.parsefromstring(ordersource, "application/xml"); the html5 data block-based way shown here works in firefox, opera, webkit-based browsers such as chrome and safari, and ie9 while ie's xml data islands work only in ie.
...itle>xml data block demo</title> <script id="purchase-order" type="application/xml"> <purchaseorder xmlns="http://example.mozilla.org/purchaseorderml"> <lineitem> <name>line item 1</name> <price>1.25</price> </lineitem> <lineitem> <name>line item 2</name> <price>2.48</price> </lineitem> </purchaseorder> </script> <script> function rundemo() { var ordersource = document.ge
telementbyid("purchase-order").textcontent; var parser = new domparser(); var doc = parser.parsefromstring(ordersource, "application/xml"); var lineitems = doc.ge
telementsbytagnamens("http://example.mozilla.org/purchaseorderml", "lineitem"); var firstprice = lineitems[0].ge
telementsbytagnamens("http://example.mozilla.org/purchaseorderml", "price")[0].textcontent; document.body.textcontent =...
...for this demo, you must create an external document called purchase_order.xml: <!doctype html> <html> <head> <title>xml data block demo</title> <script> function rundemo() { var doc = document.ge
telementbyid("purchase-order").contentdocument; var lineitems = doc.ge
telementsbytagnamens("http://example.mozilla.org/purchaseorderml", "lineitem"); var firstprice = lineitems[0].ge
telementsbytagnamens("http://example.mozilla.org/purchaseorderml", "price")[0].textcontent; document.ge
telementbyid("output-box").textcontent = "the purchase order contains " + lineitems.length + " line items.
Developing New Mozilla Features - Archive of obsolete content
once you’re familiar with an area, do the comple
tely unexpected and write a piece of documentation.
... designate someone on your team to be involved with the mozilla.org cvs repository on a regular basis the ease of integrating your feature will increase if someone on your team is intima
tely involved with the source tree.
...if you absolu
tely don't have the resources to do this, then plan for extra integration time.
Editor Embedding Guide - Archive of obsolete content
the first parameter is the nsidomwindow you just retrieved, the second is the editor type you want to create, and the third is whether you want the window editable immedia
tely or when the document is done loading.
... getcommandstate "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean) docommand no parameters example normal underline cmd_tt toggles
teletype style (monospace font) on selection.
... getcommandstate "state_all"(boolean), "state_begin"(boolean), "state_end"(boolean), "state_mixed"(boolean), "state_enabled" (boolean) docommand no parameters example normal
teletype cmd_strikethrough toggles strikethrough style on selection.
Syncing custom preferences - Archive of obsolete content
when preferences sync is enabled, firefox sync will synchronize preferences between the same application based on a whi
telist.
...to sync preferences between firefoxes, fennecs, thunderbirds, etc., ensure the prefs are whi
telisted.
... the whi
telist is determined as follows: for each services.sync.prefs.sync.<pref> preference that is set to true, firefox sync will sync the <pref> preference.
Introducing the Audio API extension - Archive of obsolete content
mple</title> </head> <body> <audio id="audio-element" src="song.ogg" controls="true" style="width: 512px;"> </audio> <script> function loadedmetadata() { channels = audio.mozchannels; rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; } var audio = document.ge
telementbyid('audio-element'); audio.addeventlistener('loadedmetadata', loadedmetadata, false); </script> </body> </html> the mozaudioavailable event as the audio is played, sample data is made available to the audio layer and the audio buffer (size defined in mozframebufferlength) gets filled with those samples.
... rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; } function audioavailable(event) { var framebuffer = event.framebuffer; var t = event.time; var text = "samples at: " + t + "\n"; text += framebuffer[0] + " " + framebuffer[1]; raw.innerhtml = text; } var raw = document.ge
telementbyid('raw'); var audio = document.ge
telementbyid('audio-element'); audio.addeventlistener('mozaudioavailable', audioavailable, false); audio.addeventlistener('loadedmetadata', loadedmetadata, false); </script> </body> </html> creating an audio stream it is also possible to create and setup an <audio> element for raw writing from script (i.e., without a src attribut...
... <audio id="a1" src="song.ogg" controls> </audio> <script> var a1 = document.ge
telementbyid('a1'), a2 = new audio(), buffers = []; function loadedmetadata() { // mute a1 audio.
PyDOM - Archive of obsolete content
for example, let's say you have xul similar to pyxultest: top-level script code says something like: button = document.ge
telementbyid("some-button") button.foo = 0 and the button itself might look like: <button id="some-button" label="click here" onclick="event.target.foo += 1; print 'foo is now', event.target.foo"/> note that (a) we have stuck an arbitrary attribute on a dom element and (b) in all cases (e.g., event handler and top-level script), the dom node needs to be explicitly specified - the globals a...
...the event handler could also have used ge
telementbyid - the point is that both the event handler and top-level script share the same namespace.
... using python ideally, you just
tell mozilla you are using python, and magically you can use python instead of javascript.
Supporting private browsing mode - Archive of obsolete content
this interface is deprecated since firefox 20, and will probably be comple
tely removed in firefox 21.see supporting per-window private browsing for details.
...let docroot = document.documen
telement; if (docroot.hasattribute("privatebrowsingmode")) { // private browsing mode is enabled } if (docroot.getattribute("privatebrowsingmode") == "temporary") { // private browsing mode is temporary } if (docroot.getattribute("privatebrowsingmode") == "permanent") { // private browsing mode is permanent for this session } turning private browsing on and off extensions can turn private b...
... from that point until we restore the original value of the private browsing mode setting, things are done priva
tely.
Tamarin build documentation - Archive of obsolete content
windows 32 and 64 bit mac osx 10.4, 10.5 on ppc mac osx 10.5, 10.6 on in
tel linux 32 and 64 bit solaris 10 on sparc android 2.2 on arm windows mobile 6.5 mips (linux) sh4 (linux) getting the tamarin source the tamarin source resides in mercurial at tamarin central.
... in
tel macs build correctly by setting archs=i386.
... this is a shared resource, each request takes approxima
tely 2+ hours to run so please use wisely.
Tamarin Build System Documentation - Archive of obsolete content
the test phase takes approxima
tely 1 hour 45 minutes.
... the buildbot scripts are located in the tamarin repository, get a current copy in your test repository cd into the build/buildbot/slaves directory: cd build/buildbot/slaves copy the your platform scripts directory into the scripts directory and cd into the new scripts directory: cp -r mac-in
tel-10_5/scripts .
...ory, test/run-smokes.txt, assume the start directory is test format is cd testdir; command to run test above the test should be a # comment describing why the test in the smokes, when test failed, possibly a bugzilla bug the tests can be run by following the above instructions for running buildbot scripts locally and executing the all/run-smoke-tests.sh as a rule any test failure should be immedia
tely added to the top of the smoke test list so the list is prioritized how to exclude tests from acceptance or mark them as known failures?
Tamarin-central rev 703:2cee46be9ce0 - Archive of obsolete content
testing summary acceptance tests have passed on the following supported platforms: * windows, 32 & 64 bit * mac ox x ppc & in
tel, 32 bit * linux, 32 bit * windows mobile arm version asc-4200 of the actionscript compiler was used for all tests.
... osdefault-jitinterpretedaggressive jit mac (os/x 10.4 in
tel, 2ghz dual core)tc-703 vs tc-700: 0.0%tc-703 vs flash10: 1.1% slowertc-703 vs tc-700: 17.4% fastertc-703 vs flash10: 165.3% fastertc-703 vs tc-700: 0.1% fastertc-703 vs flash10: 0.8% slower windows (xp pro, 2.13ghz dual core)tc-703 vs tc-700: 0.6% fastertc-703 vs flash10: 0.8% fastertc-703 vs tc-700: 16.4% fastertc-703 vs flash10: 148.7% fastertc-703 vs tc-700: 0.1% slowertc-703 vs flash10: 5.2% faster linux (ubuntu linux...
... osdefault-jitinterpretedaggressive jit mac (os/x 10.4 in
tel, 2ghz dual core)tc-703 vs tc-700: 2.0% smallertc-703 vs tc-663: 7.8% smallertc-703 vs tc-700: 7.1% largertc-703 vs tc-663: 14.6% largertc-703 vs tc-700: 16.4% largertc-703 vs tc-663: 2.1% larger windows (xp pro, 2.13ghz dual core)tc-703 vs tc-700: 3.2% largertc-703 vs tc-663: 7.6% largertc-703 vs tc-700: 3.9% largertc-703 vs tc-663: 12.4% largertc-703 vs tc-700: 3.3% largertc-703 vs tc-6...
The new nsString class implementation (1999) - Archive of obsolete content
disclaimer: i absolu
tely hate string classes.
... nsautostring use these locally in cases where you don't want to incur heap allocation unless absolu
tely necessary.
...the i18n folks will
tell you it's better to use a wide string and convert to 1-byte forms for this purpose even though there is a performance penalty for doing so.
Using XPInstall to Install Plugins - Archive of obsolete content
by refreshing your plugin, you're ensuring that the plugin is available for use immedia
tely, without obliging the user to restart their browser.
...// by passing 'true' we are
telling the install script to block // on the execution of the installable, and do it synchronously // must call performinstall to make it all happen...
...xpinstall can therefore be the "agent of delivery" to streamline the download of the exe software, but ultima
tely, the logic of installation and uninstallation will be handled by exe, which can then create files and registry entries and also clean up after itself upon removal.
collapse - Archive of obsolete content
before when the grippy is clicked, the element immedia
tely before the splitter in the same parent is collapsed so that its width or height is 0.
... after when the grippy is clicked, the element immedia
tely after the splitter in the same parent is collapsed so that its width or height is 0.
... both either the element immedia
tely before the splitter, or the element immedia
tely after the splitter can be collapsed, if the size of that element would fall below the minimum size due to the position of the splitter.
Building accessible custom components in XUL - Archive of obsolete content
<caption>it looks like a column header, but it's not</caption> so, before we do anything else, we need to
tell assistive technologies that all of these unrelated elements are actually related.
...<code> var gfocuscell = null; function install_handlers() { var spreadsheet = window.document.ge
telementbyid('accjaxspreadsheet'); spreadsheet.addeventlistener('focus', spreadsheet_focus, true); spreadsheet.addeventlistener('click', spreadsheet_click, true); } function spreadsheet_focus(e) { if (e.target.tagname == 'grid') { if (!gfocuscell) { gfocuscell = e.target.ge
telementsbytagname('label')[0]; } gfocuscell.focus(); } else { gfocu...
...<code> function install_handlers() { var spreadsheet = window.document.ge
telementbyid('accjaxspreadsheet'); spreadsheet.addeventlistener('keypress', spreadsheet_keypress, true); spreadsheet.addeventlistener('focus', spreadsheet_focus, true); spreadsheet.addeventlistener('click', spreadsheet_click, true); } </code> with this new event handler and associated helper functions, we can navigate between cells and headers using the arrow keys.
Dynamically modifying XUL-based user interface - Archive of obsolete content
the most well known dom method is probably document.ge
telementbyid(), which returns an element, given its id.
...var element = document.ge
telementbyid("someelement"); while(element.haschildnodes()){ element.removechild(element.firstchild); } inserting menu items to a menu this example adds two new menu items to a <menupopup>: to the start and to the end of it.
... function createmenuitem(alabel) { const xul_ns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var item = document.createelementns(xul_ns, "menuitem"); // create a new xul menuitem item.setattribute("label", alabel); return item; } var popup = document.ge
telementbyid("mypopup"); // a <menupopup> element var first = createmenuitem("first item"); var last = createmenuitem("last item"); popup.insertbefore(first, popup.firstchild); popup.appendchild(last); you can also use appendchild() and insertbefore() to move existing elements.
ContextMenus - Archive of obsolete content
function checkcontextmenu(event) { if (event.target.localname == "textbox") event.preventdefault(); } function init() { var container = document.ge
telementbyid("container"); container.addeventlistener("contextmenu", checkcontextmenu, true); } the 'checkcontextmenu' function checks to see if the textbox was the target of the context menu and, if so, cancels the event using the preventdefault method.
... <script> function showhidedeleteitem() { var deleteitem = document.ge
telementbyid("delete"); var rows = document.ge
telementbyid("rows"); deleteitem.hidden = (rows.childnodes.length == 0); } </script> <menupopup id="inssel-menu" onpopupshowing="showhidedeleteitem()"> <menuitem label="insert"/> <menuitem id="delete" label="delete"/> </menupopup> in this example, the showhidedeleteitem function is called when the popupshowing event is fired.
... var element = aevent.target.triggernode; var isimage = (element instanceof components.interfaces.nsiimageloadingcontent && element.currenturi); document.ge
telementbyid("enlarge").hidden = !isimage; document.ge
telementbyid("details").hidden = !isimage; } </script> <menupopup id="contentareacontextmenu" onpopupshowing="showhideitems(event)"> <menuitem label="copy"/> <menuitem id="enlarge" label="enlarge image"/> <menuitem id="details" label="image details"/> </menupopup> <browser src="http://www.mozilla.org" context="contentareacontextmenu"/> ...
PopupEvents - Archive of obsolete content
<script> function openfilemenu() { var filemenu = document.ge
telementbyid("file-menu"); filemenu.addeventlistener("popupshown", filemenuopened, false); filemenu.open = true; } function filemenuopened(event) { if (event.target != document.ge
telementbyid("file-menupopup")) return; var filemenu = document.ge
telementbyid("file-menu"); filemenu.removeeventlistener("popupshown", filemenuopened, false); var openmenu = document.ge
telementbyid("open-...
...<panel onpopuphiding="document.ge
telementbyid('search').value = '';"> <textbox id="search"/> <button label="search" oncommand="dosearch();"/> </panel> you can prevent a popup from hiding by calling the event's preventdefault method.
...you can
tell that the entire chain is closed when the topmost menu receives a popuphidden event.
Property - Archive of obsolete content
mmandmanager completedefaultindex container contentdocument contentprincipal contenttitle contentview contentvieweredit contentviewerfile contentwindow contextmenu control controller controllers crop current currentindex currentitem currentnotification currentpage currentpane currentset currenturi customtoolbarcount database datasources date da
teleadingzero datevalue decimalplaces decimalsymbol defaultbutton defaultvalue description dir disableautocomplete disableautocomplete disableautoselect disabled disablekeynavigation dlgtype docshell documentcharsetinfo editable editingcolumn editingrow editingsession editor editortype emptytext deprecated since gecko 2 enablecolumndrag eventnode fir...
...rwhilesearching image increment inputfield inverted is24hourclock ispm issearching iswaiting itemcount label labelelement lastpermanentchild lastselected left linkedpanel listboxobject locked markupdocumentviewer max maxheight maxlength maxrows maxwidth menu menuboxobject menupopup min minheight minresultsforpopup minwidth minute minu
teleadingzero mode month monthleadingzero name next nomatch notificationshidden object observes onfirstpage onlastpage open ordinal orient pack pagecount pageid pageincrement pageindex pagestep parentcontainer palette persist persistence placeholder pmindicator popup popupboxobject popupopen position predicate preferenceelements prefe...
...ebprogress width wizardpages wraparound year yearleadingzero related dom element properties dom:element.attributes dom:element.baseuri dom:element.childelementcount dom:element.childnodes dom:element.children dom:element.clientheight dom:element.clientleft dom:element.clienttop dom:element.clientwidth dom:element.clonenode dom:element.firstchild dom:element.firs
telementchild dom:element.lastchild dom:element.las
telementchild dom:element.localname dom:element.namespaceuri dom:element.nex
telementsibling dom:element.nextsibling dom:element.nodename dom:element.nodetype dom:element.nodevalue dom:element.ownerdocument dom:element.parentnode dom:element.prefix dom:element.previouselementsibling dom:element.previoussibling dom:element...
Template Builder Interface - Archive of obsolete content
getservice(components.interfaces.nsirdfservice); var ds = rdf.getdatasource("http://www.xulplanet.com/ndeakin/tests/xul/template-guide-streets.rdf"); var tree = document.ge
telementbyid("thetree"); tree.database.adddatasource(ds); tree.builder.rebuild(); this is the typical way to add a datasource to an element, in this case to the tree with the id 'thetree'.
...fortuna
tely in this situation, you can just set the datasources attribute (or the corresponding property) to the datasources that you want.
... for instance: var tree = document.ge
telementbyid("thetree"); tree.datasources = "template-guide-photos5.rdf template-guide-streets.rdf"; this will also change the datasources used.
Textbox (XPFE autocomplete) - Archive of obsolete content
this attribute only works correctly in seamonkey 1.x; for thunderbird and seamonkey 2.0 you should also set the enablehistory attribute; as of gecko 2.0 this attribute is comple
tely superseded by it.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
... related interfaces nsiaccessibleprovider, nsidomxulmenulis
telement ...
Box Objects - Archive of obsolete content
the layout object associated with an element can be removed and a comple
tely different type of object created just by changing the css display property, among others.
...example 2 : source view <script> function showpositionandsize() { var labelbox = document.ge
telementbyid('thelabel').boxobject; alert("position is (" + labelbox.x + "," + labelbox.y + ") and size is (" + labelbox.width + "," + labelbox.height + ")"); } </script> <button label="hide" oncommand="document.ge
telementbyid('thelabel').hidden = true;"/> <button label="show" oncommand="document.ge
telementbyid('thelabel').hidden = false;"/> <button label="collapse...
..." oncommand="document.ge
telementbyid('thelabel').collapsed = true;"/> <button label="uncollapse" oncommand="document.ge
telementbyid('thelabel').collapsed = false;"/> <button label="show position/size" oncommand="showpositionandsize();"/> <label id="thelabel" value="i am a label"/> note that if you hide and collapse the label, it will be treated as hidden.
Creating Dialogs - Archive of obsolete content
var somefile=document.ge
telementbyid('enterfile').value; window.opendialog("chrome://findfile/content/showdetails.xul","showmore", "chrome",somefile); in this example the dialog showdetails.xul is displayed.
...for example: var fl = window.arguments[0]; document.ge
telementbyid('thefile').value = fl; this is an effective way to pass values to the new window.
...ion label="select favourite fruit"/> <radio id="orange" label="oranges because they are fruity"/> <radio id="violet" selected="true" label="strawberries because of their colour"/> <radio id="yellow" label="bananas because they are pre-packaged"/> </groupbox> </dialog> the buttons elements can be accessed with the following javascript // the accept button var acceptbutt = document.documen
telement.getbutton("accept") more examples more examples in dialogs and prompts (code snippets).
Focus and Selection - Archive of obsolete content
example 2 : source view <script> function displayfocus(){ var elem=document.ge
telementbyid('sbar'); elem.setattribute('value','enter your phone number.'); } </script> <textbox id="tbox1"/> <textbox id="tbox2" onfocus="displayfocus();"/> <description id="sbar" value=""/> the focus event, when it occurs, will call the displayfocus function.
...example 3 : source view <window id="focus-example" title="focus example" onload="init();" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script> function init(){ addeventlistener("focus",setfocusedelement,true); } function setfocusedelement(){ var focused = document.commanddispatcher.focusedelement; document.ge
telementbyid("focused").value = focused.tagname; } </script> <hbox> <label control="username" value="user name:"/> <textbox id="username"/> </hbox> <button label="hello"/> <checkbox label="remember this decision"/> <label id="focused" value="-no focus-"/> </window> in this example, a focus event handler is attached the window.
...the following example demonstrates this: example 5 : source view <textbox id="addr"/> <button label="focus" oncommand="document.ge
telementbyid('addr').focus()"/> or, you can use the methods advancefocus and rewindfocus on the command dispatcher.
Skinning XUL Files by Hand - Archive of obsolete content
in the very near future, it will be possible to skin xul files dynamically and comple
tely -- by pressing a button, selecting a skin from a menu, or by accepting a skin from over the web.
...the skin will reside in a single css file, appropria
tely named drxul.css.
...what you have done manually in this article will be done dynamically and much more comple
tely by a mechanism called thechrome registry.
Tree Box Objects - Archive of obsolete content
example 1 : source view <script> function doscroll(){ var value = document.ge
telementbyid("tbox").value; var tree = document.ge
telementbyid("thetree"); var boxobject = tree.boxobject; boxobject.queryinterface(components.interfaces.nsitreeboxobject); boxobject.scrolltorow(value); } </script> <tree id="thetree" rows="4"> <treecols> <treecol id="row" label="row" primary="true" flex="1"/> </treecols> <treechildren> <treeitem label="row 0"/> <treeitem l...
... example 2 : source view <script> function updatefields(event){ var row = {}, column = {}, part = {}; var tree = document.ge
telementbyid("thetree"); var boxobject = tree.boxobject; boxobject.queryinterface(components.interfaces.nsitreeboxobject); boxobject.getcellat(event.clientx, event.clienty, row, column, part); if (column.value && typeof column.value != "string") column.value = column.value.id; document.ge
telementbyid("row").value = row.value; document.ge
telementbyid("column").value = column.value; ...
... document.ge
telementbyid("part").value = part.value; } </script> <tree id="thetree" flex="1" onmousemove="updatefields(event);"> <treecols> <treecol id="utensil" label="utensil" primary="true" flex="1"/> <treecol id="count" label="count" flex="1"/> </treecols> <treechildren> <treeitem> <treerow> <treecell label="fork"/> <treecell label="5"/> </treerow> </treeitem> <treeitem> <treerow> <treecell label="knife"/> <treecell label="2"/> </treerow> </treeitem> <treeitem> <treerow> <treecell label="spoon"/> <treecell label="8"/> </treerow> </treeitem> </treechildren> </tree> <label value="row:"/> <label id="row"/> <label value="column:"/> <label id="column"/> <label value="...
Tree View Details - Archive of obsolete content
function init() { document.ge
telementbyid("elementlist").view = treeview; } the custom tree view will need to implement a number of methods, of which the important ones will be examined individually.
... whether opening or closing a row, we need to
tell the tree to repaint the twisty in the new state.
... cycleheader: function(col, elem) {}, selectionchanged: function() {}, cyclecell: function(idx, column) {}, performaction: function(action) {}, performactiononcell: function(action, index, column) {}, getrowproperties: function(idx, prop) {}, getcellproperties: function(idx, column, prop) {}, getcolumnproperties: function(column, element, prop) {}, }; function init() { document.ge
telementbyid("elementlist").view = treeview; } ]]></script> </window> next, we'll look in more detail at the tree box object.
XUL Event Propagation - Archive of obsolete content
for example, if an event handler at the menu is handling an event raised by one of the menu items, then the menu should be able to identify the raising element and take the appropriate action, as in the following example, where a javascript function determines which menuitem was selected and responds appropria
tely: <script> function docmd(el) { v = el.getattribute("value"); if (v == "new") alert("new clicked"); else if (v == "open") alert("open clicked"); else alert("close clicked"); } </script> ...
...in another example, an onload event handler for a xul window can register a box element to capture all the click events that are raised from its child elements: var bbox = document.ge
telementbyid("bigbox"); if (bbox) bbox.addeventlistener("click", function() { alert('captured'); }, true); ...
...the syntax for this in xul is as follows: element = document.ge
telementbyid("id of the element"); element.addeventlistener(event name, event handler function, whether to register a capturing listener); the event handler code argument can be in-line code or a function.
preference - Archive of obsolete content
type ge
telementvalue(in domelement element); retrieves the value that should be written to preferences based on the current state of the supplied element.
... void se
telementvalue(in domelement element); initializes the supplied element from the value stored in the preference.
... inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributenode()...
radiogroup - Archive of obsolete content
attributes disabled, focused, preference, tabindex, value properties accessibletype, disabled, focuseditem, itemcount, selectedindex, selecteditem, tabindex, value methods appenditem, checkadjacen
telement, getindexofitem, getitematindex, insertitemat, removeitemat examples <radiogroup> <radio id="orange" label="red"/> <radio id="violet" label="green" selected="true"/> <radio id="yellow" label="blue"/> </radiogroup> attributes disabled type: boolean indicates whether the element is disabled or not.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
... checkadjacen
telement( dir ) return type: no return value deselects the currently selected radio button in the group and selects the one adjacent to it.
tree - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
... column: function getcellchecked(tree, columnid) { var arr = []; var column = tree.columns.getnamedcolumn(columnid); for (var i = 0; i < tree.view.rowcount; i++) { if (tree.view.getcellvalue(i, column) == 'true') arr.push(i); } return arr; } to get the text value for a specific column (for example column 'age') from the currently focused row in the tree: var t = document.ge
telementbyid('mytree'); document.title = t.view.getcelltext(t.currentindex,t.columns.getnamedcolumn('age')); to select the checkbox and display the cell's text value, you can use code like the following.
...-tree-cell-text(selected) { color: #000000; } treechildren::-moz-tree-cell-text(odd, selected) { color: #000000; } treechildren::-moz-tree-row(hover) {background-color: #ffffaa !important;} treechildren:-moz-tree-column { border-right:1px solid rgb(220,220,220) !important; } the javascript to get the text for the selected row/rows: function getrowcellvalues() { var tree = document.ge
telementbyid('mytree'); for (var i = 0; i < tree.view.rowcount; i++) { if (tree.view.getcellvalue(i, tree.columns.getcolumnat(0)) == 'true'){ alert(tree.view.getcelltext(i, tree.columns.getnamedcolumn("name"))); } } } this way, you can get the tree cell values of the selected checkbox of the corresponding row.
Application Update - Archive of obsolete content
as far as i can
tell enabling the options --enable-updater and --enable-update-packaging on your configure will build you mar.
...other apps may wish to show this ui, and supply // a whatsnewurl field in their brand.properties that contains a link to a page // which
tells users what's new in this new update.
... update.xml the format is outlined here process as best i can
tell here's how the update process works.
Getting started with XULRunner - Archive of obsolete content
here is the application root chrome.manifest: manifest chrome/chrome.manifest step 6: set up preferences the prefs.js file
tells xulrunner the name of the xul file to use as the main window.
... main.js: function showmore() { document.ge
telementbyid("more-text").hidden = false; } for more information about xul see: xul.
... alternative: run xul apps with firefox with firefox 3 and later, you can
tell the firefox executable to run a xul application from the command line.
How to enable locale switching in a XULRunner application - Archive of obsolete content
modify the application preferences first, you need to
tell xulrunner that your application wishes to ignore the default os locale and that it will do its own choosing instead.
...itoolkitchromeregistry); var selectedlocale = xulchromereg.getselectedlocale("localeswitchdemo"); var availablelocales = toolkitchromereg.getlocalesforpackage("localeswitchdemo"); // render locale menulist by iterating through the query result from getlocalesforpackage() const xul_ns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var localelistbox = document.ge
telementbyid("locale-listbox"); var selecteditem = null; while(availablelocales.hasmore()) { var locale = availablelocales.getnext(); var listitem = document.createelementns(xul_ns, "listitem"); listitem.setattribute("value", locale); listitem.setattribute("label", locale); if (locale == selectedlocale) { // is this the current locale?
... var localelistbox = document.ge
telementbyid("locale-listbox"); var newlocale = localelistbox.selecteditem.value; // write preferred locale to local user config var prefs = components.classes["@mozilla.org/preferences-service;1"].
Adobe Flash - Archive of obsolete content
fortuna
tely, mach-o browsers based on netscape gecko expose this information in their user-agent string.
... performance and flash as is the case with any plug-in content, flash content has the potential to slow down or even comple
tely stall not just the tab it's running in, but the entire browser and even the entire computer it's being used on.
... var myflash = document.ge
telementbyid("myflash").setvariable("myvar", sendtext); a more expanded code example that shows how example 2 was created is shown in this source listing.
Encryption and Decryption - Archive of obsolete content
encryption is the process of transforming information so it is unin
telligible to anyone but the intended recipient.
... decryption is the process of transforming encrypted information so that it is in
telligible again.
...on the other hand, symmetric-key ciphers can achieve approxima
tely the same level of strength with an 80-bit key for most algorithms.
SSL and TLS - Archive of obsolete content
because the key size is so large, there are approxima
tely 3.7 * 1050 possible keys.
...the rc4 and rc2 ciphers have 128-bit encryption, which permits approxima
tely 3.4 * 1038 possible keys.
...des 56-bit encryption permits approxima
tely 7.2 * 1016 possible keys.
Styling the Amazing Netscape Fish Cam Page - Archive of obsolete content
unfortuna
tely, a few browsers don't get this right, and end up flowing the cards as a single vertical column instead of putting the fish side by side.
... floating fish with the cards set up to float, the next step was to place the images appropria
tely.
...: 45%; margin: 1em 2% 0 2%;} div.card img {float: left; margin: 4px 0 0 0; border: 1px solid #339;} div.card h3 {border: 1px solid #339; border-left: 5px double #339; background: #eec url(body-bg-tan.jpg) bottom left no-repeat fixed; color: #339;} finishing the style adding the background to the heading containing the name of the fish created three problems: the double border was comple
tely covered up by the image.
Using the Right Markup to Invoke Plugins - Archive of obsolete content
for instance, the param name="movie"
tells the flash plugin the location of the swf file to start playing.
...at a minimum, web authors will have to nest some alternate text inside their object elements
telling users where to obtain the missing component.
...47, which don't understand the <param name="movie" value="animation.swf"> param element, which is supposed to
tell the flash player which animation to start playing.
Game distribution - Game development
direct link distribution and instant play you don't have to
tell people to search for your game in an app store with html5 games.
...the biggest desktop store for games is defini
tely steam — indie developers can get on steam via the steam direct program.
... other alternative tools are: in
tel xdk — an exciting alternative, similar to cocoonio.
Game promotion - Game development
website and blog you should defini
tely create your own website containing all the information about your games, so people can see what you've worked on.
...remember to not be too pushy on
telling everyone about your games — you're not a walking advertisement.
... if you want to learn more about the etiquette of contacting the press you should defini
tely check out how to contact press - a great guide from pixel prospector, and the video game journaliser site curated by them for the list of sites to contact.
Building up a basic demo with A-Frame - Game development
dd this just before the closing </a-scene> element: <a-camera position="0 1 4" cursor-visible="true" cursor-scale="2" cursor-color="#0095dd" cursor-opacity="0.5"> </a-camera> we've also defined a cursor for the given camera, using the cursor-* attributes (by default it is invisible.) — we've set its scale so it will more easily visible, its color, and some opacity so it won't comple
tely covering the objects behind it.
...the duration is set to 4 seconds, and it will be repeated indefini
tely.
...again, the animation is being repeated indefini
tely.
Mobile accessibility - Learn web development
long gone are the days when mobile devices ran comple
tely different web technologies to desktop browsers, forcing developers to use browser sniffing and serve them comple
tely separate sites (although quite a few companies still detect usage of mobile devices and serve them a separate mobile domain).
...there are certain situations where zooming might break the ui; in such cases, if you feel that you absolu
tely need to disable zoom, you should provide some other kind of equivalent, such as a control for increasing the text size in a way that doesn't break your ui.
...for example: types number,
tel, and email display suitable virtual keyboards for entering numbers/
telephone numbers.
What is accessibility? - Learn web development
people with cognitive impairments cognitive impairment refers to a broad range of disabilities, from people with in
tellectual disabilities who have the most-limited capabilities, to all of us as we age and have difficulty thinking and remembering.
... in the u.s., “in
tellectual disabilities” is the new term for “mental retardation.” in the u.k., “in
tellectual disabilities” is commonly “learning disabilities” or “learning difficulties”.
... so while the wcag is a set of guidelines, your country will probably have laws governing web accessibility, or at least the accessibility of services available to the public (which could include websites,
television, physical spaces, etc.) it is a good idea to find out what your laws are.
Cascade and inheritance - Learn web development
while working through this lesson may seem less immedia
tely relevant and a little more academic than some other parts of the course, an understanding of these things will save you much pain later on!
...however, we strongly recommend that you never use it unless you absolu
tely have to.
...this is defini
tely the most complicated thing we've covered so far in the course, and is something that even professional web developers sometimes find tricky.
CSS values and units - Learn web development
this takes a value from 0–100%, where 0 is no light (it will appear comple
tely black) and 100% is full light (it will appear comple
tely white) we can update the rgb example to use hsl colors like this: just as rgb has rgba, hsl has an hsla equivalent, which gives you the same ability to specify the alpha channel.
...these keywords are more accura
tely described as identifiers, a special value that css understands.
...we can't do this calculation beforehand because we don't know what 20% of the parent will be, so we use calc() to
tell the browser to do it for us.
What is a Domain Name? - Learn web development
tlds
tell users the general purpose of the service behind the domain name.
...most of them provide a “whois” service that
tells you whether a domain name is available.
... if your computer does not know which ip is behind the mozilla.org name, it goes on to ask a dns server, whose job is precisely to
tell your computer which ip address matches each registered domain name.
Define terms with HTML - Learn web development
special case: abbreviations it's best to mark abbreviations specially with <abbr>, so that screen readers read them appropria
tely and so that you can operate on all abbreviations uniformly.
...the contents of title are comple
tely hidden from your users, unless they're using a mouse and they happen to hover over the abbreviation.
...the matching description follows immedia
tely, contained within one or more <dd> elements.
Document and website structure - Learn web development
this is the one part of the website that defini
tely will vary from page to page!
... this is because visuals don't
tell the whole story.
... note: colorblind people represent around 4% of the world population or, to put it another way, approxima
tely 1 in every 12 men and 1 in every 200 women are colorblind.
What’s in the head? Metadata in HTML - Learn web development
you should see something like this: it should now be comple
tely obvious where the <h1> content appears, and where the <title> content appears!
... it may change over time): <meta name="description" content="the mdn web docs site provides information about open web technologies including html, css, and apis for both web sites and progressive web apps."> now search for "mdn web docs" in your favorite search engine (we used google.) you'll notice the description <meta> and <title> element content used in the search result — defini
tely worth having!
... note: in google, you will see some relevant subpages of mdn web docs listed below the main homepage link — these are called si
telinks, and are configurable in google's webmaster tools — a way to make your site's search results better in the google search engine.
HTML table basics - Learn web development
unfortuna
tely, a lot of people used to use html tables to lay out web pages, e.g.
...fortuna
tely, table headers and cells have the colspan and rowspan attributes, which allow us to do just those things.
... providing common styling to columns there is one last feature we'll
tell you about in this article before we move on.
Making decisions in your code — conditionals - Learn web development
if you want to go outside, make sure to put some sunscreen on.'; } } even though the code all works together, each if...else statement works comple
tely independently of the other one.
...0; } .output li { display: block; float: left; width: 25%; border: 2px solid white; padding: 5px; height: 40px; background-color: #4a2db6; color: white; } html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
...extcolor; }</textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
Fetching data from the server - Learn web development
the ajax model involves using a web api as a proxy to more in
telligently request data rather than just having the browser reload the entire page.
... request.onload = function() { poemdisplay.textcontent = request.response; }; the above is all set up for the xhr request — it won't actually run until we
tell it to, which is done using the send() method.
... effectively, the function passed into then() is a chunk of code that won't run immedia
tely.
Useful string methods - Learn web development
em); } } </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
...stitem); } </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
...titem); } </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution"> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); let code = textarea.value; let userentry = textarea.value; function updatecode() { eval(textarea.value); } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; solutionentry = jssolution; solution.value = 'show solution'; ...
Object-oriented JavaScript for beginners - Learn web development
you can also define the same feature separa
tely in different classes, as each definition of that feature will be in a different namespace.
...fortuna
tely, javascript provides us with a handy shortcut, in the form of constructor functions — let's make one now!
... let's look at the constructor calls again: let person1 = new person('bob'); let person2 = new person('sarah'); in each case, the new keyword is used to
tell the browser we want to create a new object instance, followed by the function name with its required parameters contained in parentheses, and the result is stored in a variable — very similar to how a standard function is called.
CSS performance optimization - Learn web development
to create a non-blocking css link, move the not-immedia
tely used styles, such as print styles, into separate file, add a <link> to the html mark up, and add a media query, in this case stating it's a print stylesheet.
...
tell the browser when the style sheet should be applied by adding a media attribute with the media query.
... will-change property the css will-change property
tells browsers which properties of an element are expected to change enabling browsers to set up optimizations before the element is actually changed, improving performance by doing potentially expensive work before it is required.
Ember interactivity: Events, classes and state - Learn web development
add the new line shown below to your header.hbs file: <input class='new-todo' aria-label='what needs to be done?' placeholder='what needs to be done?' autofocus {{on 'keydown' this.onkeydown}} > this new attribute is inside double curly braces, which
tells you it is part of ember's dynamic templating syntax.
... coming back to our browser tab with the app running, we can type whatever we want, and when we hit enter we'll be greeted with an alert message
telling us exactly what we typed.
...whenever you enter a new todo item, a new list item appears below the text input, but unfortuna
tely it always says "buy movie tickets".
Introduction to client-side frameworks - Learn web development
the code that will render our items on the page might read something like this: function rendertodolist() { const frag = document.createdocumentfragment(); state.tasks.foreach(task => { const item = buildtodoitemel(task.id, task.name); frag.appendchild(item); }); while (todolis
tel.firstchild) { todolis
tel.removechild(todolis
tel.firstchild); } todolis
tel.appendchild(frag); } we've now got well over thirty lines of code dedicated just to the ui – just to the step of rendering something in the dom – and at no point do we add classes that we could use later to style our list-items!
...this snippet reduces approxima
tely thirty-two lines of code down to six lines.
...no matter how you build for the web, the end result, the layer that your users ultima
tely interact with, is html.
Starting our Svelte Todo list app - Learn web development
for example: <button class="btn toggle-btn" aria-pressed="true"> <span class="visually-hidden">show</span> <span>all</span> <span class="visually-hidden">tasks</span> </button> here, aria-pressed
tells assistive technology (like screen readers) that the button can be in one of two states: pressed or unpressed.
... the aria-labelledby attribute
tells assistive technologies that we're treating our <h2> with an id of list-heading as the label that describes the purpose of the list beneath it.
... moreover, our editor can display this warning even before calling the compiler: you can
tell svelte to ignore this warning for the next block of markup with a comment beginning with svelte-ignore, like this: <!-- svelte-ignore a11y-missing-attribute --> <img height="32" width="88" src="https://udn.realityripple.com/samples/b0/98dase3c7d.png"> note: with vscode you can automatically add this ignore comment by clicking on the quick fix...
Getting started with Svelte - Learn web development
.gitignore:
tells git which files or folder to ignore from the project — useful if you decide to include your app in a git repo.
...this configuration file
tells rollup how to compile and build your app.
... using the svelte repl a repl (read–eval–print loop) is an interactive environment that allows you to enter commands and immedia
tely see the results — many programming languages provide a repl.
Focus management with Vue refs - Learn web development
however, it also means you often should not edit your html elements directly through native browser apis (like document.ge
telementbyid) when using frameworks, because it results in the vdom and real dom going out of sync.
...because vue is trying to optimize and batch changes, it won't immedia
tely update the dom when we set isediting to false.
... mounted() { const labelinputref = this.$refs.labelinput; labelinputref.focus(); } now when you activate the "edit" button with your keyboard, focus should immedia
tely be moved to the edit <input>.
Introduction to cross browser testing - Learn web development
on the other hand, it is not ok for a site to work fine for sighted users, but be comple
tely inaccessible for visually impaired users because their screen reader application can't read any of the information stored on it.
...as a web developer, you need to agree on a range of browsers and devices that the code defini
tely needs to work on with the site owner, but beyond that, you need to code defensively to give other browsers the best chance possible of being able to use your content.
...this situation is a lot less bad than it used to be; back when ie4 and netscape 4 were competing to be the dominant browser in the 1990s, browser companies delibera
tely implemented things differently to each other to try to gain competitive advantage, which made life hell for developers.
Setting up your own test automation environment - Learn web development
lambdatest getting selenium tests to run remo
tely on lambdatest is very simple.
... browser.executescript("lambda-status=failed"); browserstack getting selenium tests to run remo
tely on browserstack is easy.
... if you now go back to your browserstack automation dashboard page, you should see your test session available, as before, but with the updated data attached to it: sauce labs getting selenium tests to run remo
tely on sauce labs is also very simple, and very similar to browserstack albeit with a few syntactic differences.
Introducing a complete toolchain - Learn web development
this
tells the npm tool that these particular dependencies are only needed for development (npm therefore lists them in the package.json file under devdependencies, not dependencies).
... if the browser tries to run the source javascript it will immedia
tely complain; the project needs a build tool to transform the source code to something the browser can consume without issue.
... you could also try using eslint and prettier too — try delibera
tely removing a load of the whitespace from one of your files and try put prettier on it to clean it up, or introduce a syntax error into one of your javascript files and see what errors eslint gives you when you try to use parcel to build it again.
Software accessibility: Where are we today?
unfortuna
tely, the unit is not currently produced, although there is occasional talk of resurrecting this useful device.
...ideally, in
telligent decisions are made, so the user does not have to wade through as much non-relevant data.
...however, all these solutions fell short of providing people with disabilities with a working environment which was comple
tely accessible and usable by them.
Command line options
see the article on remo
tely debugging firefox desktop.
... -osint
tells the application that it is being launched by the os shell.
... -requestpending
tells the application that there will be a windows dde request to open the same url specified on the command line.
How Mozilla's build system works
config.status is charged with the task of
telling a tool how to build the tree.
...think of each moz.build file as a data structure
telling the build system what to do.
...these are how the execution of a moz.build file
tells the build system what to do.
Cross Process Object Wrappers
*/ var button = content.document.ge
telementbyid("click-me"); button.addeventlistener("mouseover", function (event) { sendasyncmessage("my-addon-message", {}, { element : event.target }); }, false); // chrome script /* load the frame script, then listen for the message.
... performance although the wrapper looks just like an object comple
tely contained in the chrome script scope, it's really just a reference to an object in the content process.
...the content process can respond immedia
tely to the cpow call: there is still a performance cost to the cpow in this situation, because the cpow call is an ipc call instead of a simple property access in the same process.
Performance best practices for Firefox front-end engineers
normally, the changes to the dom just result in the standard style calculation occurring immedia
tely after the javascript has finished running during the 16ms window, inside the "style" step.
... it should be possible to write a test that gets the nsidomwindowutils for a browser window, records the number of styleflushes, then synchronously calls the function that you want to test, and immedia
tely after checks the styleflushes attribute again.
...normally, however, the changes to the dom just result in the standard style calculation that occurs immedia
tely after the javascript has finished running during the 16ms window.
Gecko SDK
issues with the os x sdk if you need to use the xpidl utility to compile idl files on os x, it's likely that you will receive a strange error when running the tool that looks something along the lines of this: dyld: library not loaded: /opt/local/lib/libintl.3.dylib referenced from: /users/varmaa/xulrunner-sdk/bin/./xpidl reason: image not found trace/bpt trap unfortuna
tely, this is caused by a problem with the sdk build process which cannot currently be resolved (see bugzilla bug #430274).
... mac in
tel gecko 1.8 sdk the official mac 1.8 sdk is a ppc version.
... this is an unofficial in
tel build.
How to get a stacktrace for a bug report
a stacktrace will
tell mozilla developers what crashed and provide a starting point for investigating its cause.
...be sure that you check the "
tell mozilla about this crash" checkbox and click the restart button.
...
tell us the id of the report you submitted.
Extending a Protocol
it's quite involved and, unfortuna
tely, all steps need to be done before we can successfully recompile.
...unfortuna
tely, it's not really fully documented anywhere - and the ipdl parser gets easily confused (hence us excluding comments below).
...scroll to the end and add private member: refptr<echochild> mechochild; } // namespace dom } // namespace mozilla navigator.cpp - getechochild() now, add the following includes at the top of the file: #include "mozilla/dom/echochild.h" #include "mozilla/dom/windowglobalchild.h" to the "ns_impl_cycle_collection_unlink_begin(navigator)" we can now
tell gecko that mechochild can participate, so let's add: ns_impl_cycle_collection_unlink(mechochild) now, the getechochild() private method will do the intial setup for us.
AsyncShutdown.jsm
for instance, at the end of phase profilebeforechange, no service is permitted to write to the profile directory (with the exception of
telemetry).
... send
telemetry read only phase
telemetry is being sent.
... this phase represents the last chance for
telemetry to write data.
Sqlite.jsm
since sqlite.jsm manages statements for you, it can perform in
telligent actions like purging all cached statements not in use, freeing memory in the process.
...this is a glorified wrapper around the pragma shrink_memory statement, which
tells sqlite to shrink its memory usage (by clearing caches, etc).
...consumers of this api can call the cancel function should they want to immedia
tely abort the execution of the statement.
Localizing with Koala
also, searchbar.dtd is no longer displayed in the "compare" view, as it has been comple
tely translated.
... here's a quick summary of what the output of the comparison means: files: "unmodified" - the file is comple
tely translated.
...also, removing files works in a similar manner: not only do you have to delete the file, but also you need to
tell mercurial to stop tracking the file with "hg remove".
Localizing without a specialized tool
with that document, users can see immedia
tely two localized files in their user interface by following closely and carefully the steps to create a language pack or a binary file that is ready for installation.
...x-testing: unchanged: 2 changed: 3 missinginfiles: 6117 missing: 13 0% of entries changed the beauty of the compare-locales output is that it
tells you all the missing files and which files you need to add and localize.
... for instance, enter the proper translation for the line "add %s" cmd_addfoundengine=add "%s" with these two string examples translated, you can now test your work to see immedia
tely where you have translated.
Mozilla Web Developer FAQ
you should not rely on mozilla’s document.all support on new pages.) the method document.ge
telementbyid() can be used instead.
...the correct way to access an element by id is to call the document.ge
telementbyid() method with the id as a string as the argument.
...for example, the existence of document.ge
telementbyid() can be checked as follows: if(document.ge
telementbyid) { /* code that uses document.ge
telementbyid() */ } why doesn’t mozilla display my alt tooltips?
Mozilla Quirks Mode Behavior
(this also applies to ge
telementsbyclassname.) stylesheets linked in the document with an advisory mime type of text/css will still be treated as css even if the server gives a content-type header other than text/css.
... in quirks mode, text-decoration is propagated into floating and absolu
tely positioned elements.
...i don't follow the code in nscssrenderingborders well enough to
tell, though.] in quirks mode a fixed width specified on a table cell resets the nowrap attribute.
BloatView
| 24 48| 3086 2| 279 |messagepump | 8 8| 30 1| 285 |mutex | 20 60| 89987 3| 302 |pcompositorchild | 412 412| 1 1| 308 |pimagebridgechild | 416 416| 1 1| the first line
tells you the pid of the leaking process, along with the type of process.
...that means no one is looking at them, and we won't be able to
tell if someone introduces a leak.
... to do so, the xpcom_mem_log_classes environment variable should be set to the name of the class from the bloatview table: xpcom_mem_log_classes=myclass mach mochitest [options] multiple class names can be specified by setting xpcom_mem_log_classes to a comma-separated list of names: xpcom_mem_log_classes=myclass,myotherclass,delibera
telyleakedclass mach mochitest [options] test harness scripts typically accept a --setenv option for specifying environment variables, which may be more convenient in some cases: mach mochitest --setenv=xpcom_mem_log_classes=myclass [options] for getting allocation stacks in automation, you can add the appropriate --setenv options to the test configurations for the platforms you're interested in.
Refcount tracing and balancing
warning: you should never use this without xpcom_mem_log_classes and/or xpcom_mem_log_objects, because without some filtering the logging will be comple
tely useless due to how slow the browser will run and how large the logs it produces will be.
... what this little tree is
telling you is that you leak one refcount overall on object 0x00253ab0.
...the make-tree.pl script accepts an option --ignore-balanced, which
tells it not to bother printing out the children of a node whose balance factor is zero.
Scroll-linked effects
<body style="height: 5000px" onscroll="document.ge
telementbyid('toolbar').style.top = math.max(100, window.scrolly) + 'px'"> <div id="toolbar" style="position: absolute; top: 100px; width: 100px; height: 20px; background-color: green"></div> </body> this implementation of sticky positioning relies on the scroll event listener to reposition the "toolbar" div.
... } else if (math.abs(destination - window.scrolly) < 200) { scrollto(window.scrollx, window.scrolly + ((destination - window.scrolly) / 2)); settimeout(snap, 20, destination); } } var timeoutid = null; addeventlistener("scroll", function() { if (timeoutid) cleartimeout(timeoutid); timeoutid = settimeout(snap, 200, parseint(document.ge
telementbyid('snaptarget').style.top)); }, true); </script> <div id="snaptarget" class="snaptarget" style="position: relative; top: 200px; width: 100%; height: 200px; background-color: green"></div> </body> in this example, there is a scroll event listener which detects if the scroll position is within 200 pixels of the top of the "snaptarget" div.
...in order to do so, we need you (yes, you!) to
tell us more about the kinds of scroll-linked effects you are trying to implement, so that we can find good ways to support them in the compositor.
about:memory
(the filename will have a .json.gz suffix.) you can then attach or upload the file appropria
tely.
...if you find any particular tree overwhelming, it can be helpful to collapse all the sub-trees immedia
tely below the root, and then gradually expand the sub-trees of interest.
... all javascript memory usage for an add-on is measured separa
tely and shown in this sub-tree.
Performance
adding a new
telemetry probe information on how to add a new measurement to the
telemetry performance-reporting system profiling javascript with shark (obsolete - replaced by instruments) how to use the mac os x shark profiler to profile javascript code in firefox 3.5 or later.
... tools/power/rapl (mac, linux) tools/power/rapl is a command-line utility in the mozilla codebase that uses the in
tel rapl interface to gather direct power estimates for the package, cores, gpu and memory.
... in
tel power gadget (windows, mac, linux) in
tel power gadget provides real-time graphs for package and processor rapl estimates.
AsyncTestUtils extended framework
returning false
tells the asynchronous driver that it should yield control up to the top-level.
...we do not mark the folders as offline and therefore do not attempt to download the messages so that they are immedia
tely available for offline use.
...we mark the folders as offline and download the messages so that they are immedia
tely available for offline use.
About NSPR
this allows a minimal timer period in of approxima
tely 12 hours.
...use of 64 bits allows a representation of times approxima
tely in the range of -30000 to the year 30000.
...depending on the platform, the functions may be implemented almost entirely in the nspr runtime or simply shims that call immedia
tely into the host operating system's offerings.
NSPR Contributor Guide
see also: xxx ownership of your contribution when you contribute something to nspr, you must have in
tellectual property rights to that contribution.
...if you snatched it from somewhere else,
tell us where; show us where the right to incorporate it into nspr exists.
...we may
tell you that you have a good idea; we may say that it really is not a good candidate for inclusion in nspr; we may give you suggestions on what would make it more generalized, hence a good candidate for inclusion in nspr.
PRIntervalTime
it should therefore never be used for intervals greater than approxima
tely 6 hours.
...they indicate that the process should wait no time (return immedia
tely) or wait forever (never time out), respectively.
...at that rate, a 32-bit register will overflow in approxima
tely 28 hours, making the maximum useful interval approxima
tely 6 hours.
NSS_3.12_release_notes.html
k_fetching cert_rev_m_forbid_network_fetching cert_rev_m_allow_implicit_default_source cert_rev_m_ignore_implicit_default_source cert_rev_m_skip_test_on_missing_source cert_rev_m_require_info_on_missing_source cert_rev_m_ignore_missing_fresh_info cert_rev_m_fail_on_missing_fresh_info cert_rev_m_stop_testing_on_fresh_info cert_rev_m_continue_testing_on_fresh_info cert_rev_mi_test_each_method_separa
tely cert_rev_mi_test_all_local_information_first cert_rev_mi_no_overall_info_requirement cert_rev_mi_require_some_fresh_info_available cert_policy_flag_no_mapping cert_policy_flag_explicit cert_policy_flag_no_any cert_enable_ldap_fetch cert_enable_http_fetch new macro in utilrename.h: smime_aes_cbc_128 the nssckbi pkcs #11 module's version changed to 1.70.
...bug 217538: softoken databases cannot be shared between multiple processes bug 294531: design new interfaces for certificate path building and verification for libpkix bug 326482: nss ecc performance problems (in
tel) bug 391296: need an update helper for shared databases bug 395090: remove duplication of pkcs7 code from pkix_pl_httpcertstore.c bug 401026: need to provide a way to modify and create new pkcs #11 objects.
...own failure in p7sign bug 324878: crlutil -l outputs false crl names bug 337010: oom crash [[@ nsc_digestkey] dereferencing possibly null att bug 343231: certutil issues certs for invalid requests bug 353371: klocwork 91117 - null pointer dereference in cert_certchainfromcert bug 353374: klocwork 76494 - null ptr derefs in cert_formatname bug 353375: klocwork 76513 - null ptr deref in nsscertifica
telist_docallback bug 353413: klocwork 76541 free uninitialized pointer in cert_findcerturlextension bug 353416: klocwork 76593 null ptr deref in nsscryptokiprivatekey_setcertificate bug 353423: klocwork bugs in nss/lib/pk11wrap/dev3hack.c bug 353739: klocwork null ptr dereferences in instance.c bug 353741: klocwork cascading memory leak in mpp_make_prime bug 353742: klocwork null ptr dereference in ...
NSS tools : certutil
-p phone specify a contact
telephone number to include in new certificates or certificate requests.
...this request is submitted separa
tely to a certificate authority and is then approved by some mechanism (automatically or by human review).
...the keys generated for certificates are stored separa
tely, in the key database.
NSS_3.12.3_release_notes.html
nss_use_decoded_cka_ec_point boolean (any non-empty value to enable)
tells nss to send ec key points across the pkcs#11 interface in the non-standard unencoded format that was used by default before nss 3.12.3.
... nss_use_shexp_in_cert_name boolean (any non-empty value to enable)
tells nss to allow shell-style wildcard patterns in certificates to match ssl server host names.
... bug 484425: need accessor function to retrieve symkey handle bug 484466: sec_error_invalid_args with nss_enable_pkix_verify=1 bug 485127: bltest crashes when attempting rc5_cbc or rc5_ecb bug 485140: wrong command line flags used to build in
tel-aes.s with solaris gas for x86_64 bug 485370: crash bug 485713: files added by red hat recently have missing texts in license headers.
certutil
-p phone specify a contact
telephone number to include in new certificates or certificate requests.
...this request is submitted separa
tely to a certificate authority and is then approved by some mechanism (automatically or by human review).
...the keys generated for certificates are stored separa
tely, in the key database.
Index
the allocation will then be retried (and may still fail.) 68 js::setoutofmemorycallback jsapi reference, reference, référence(2), spidermonkey unlike the error reporter, which is only called if the exception for an oom bubbles up and is not caught, the js::outofmemorycallback is called immedia
tely at the oom site to allow the embedding to capture the current state of heap allocation before anything is freed.
... 288 js_ge
telement jsapi reference, spidermonkey js_ge
telement examines a specified js object, obj, and its prototype chain, for an element or numeric property numbered index.
... 454 js_se
telement jsapi reference, spidermonkey js_se
telement assigns a value to a numeric property of an object.
64-bit Compatibility
amd64 pointers if mucking with pointers on amd64 (or em64-t/in
tel64), it is important to keep in mind an invariant that bits 63-48 must be sign-extended from bit 47.
...lir safety it is not immedia
tely clear from reading lir which opcodes should be used for 64-bit safety.
...to help form well-typed lir, there is a special opcode called lir_float which specifies that the associated constant value is defini
tely floating-point.
Garbage collection
if so, the engine must immedia
tely restart a full, non-incremental gc in order to reclaim some memory and continue execution.
...this is easily done by simply marking new objects immedia
tely upon allocation during an incremental gc, thus the name allocate-black.
...there are also functions to commit or decommit memory, i.e.,
tell the os that certain pages are not being used and can be thrown away instead of paged to disk.
Tracing JIT
it is correspondingly very simple: register allocation is done immedia
tely, step-by-step as code is being generated.
...the associated fragment is placed in the monitor's fragment table and the monitor returns to monitoring mode, with a high likelihood of immedia
tely transitioning to executing mode on the next bytecode interpreted.
...if that pc has itself grown hot, the monitor will immedia
tely transition to recording mode starting with the exiting pc.
JIT Optimization Outcomes
arrayrange could not accura
tely calculate the range attributes of an inline array creation.
... accessnottypedarray accessnotstring statictypedarrayuint32 statictypedarraycantcomputemask outofbounds ge
telemstringnotcached nonnativereceiver indextype se
telemnondensenontanotcached nosimdjitsupport optimization failed because simd jit support was not enabled.
...xedreadexpando icgetpropstub_unboxedarraylength icgetpropstub_typedarraylength icgetpropstub_domproxyshadowed icgetpropstub_domproxyunshadowed icgetpropstub_genericproxy icgetpropstub_argumentslength icsetpropstub_slot icsetpropstub_genericproxy icsetpropstub_domproxyshadowed icsetpropstub_domproxyunshadowed icsetpropstub_callsetter icsetpropstub_addslot icsetpropstub_setunboxed icge
telemstub_readslot icge
telemstub_callgetter icge
telemstub_readunboxed icge
telemstub_dense icge
telemstub_densehole icge
telemstub_typedarray icge
telemstub_argselement icge
telemstub_argselementstrict icse
telemstub_dense icse
telemstub_typedarray icnamestub_readslot icnamestub_callgetter call inlining outcomes optimization outcomes of attempts to inline function calls.
JSAPI User Guide
argc
tells how many actual arguments the caller passed, and js_argv(cx, vp) returns an array of those arguments.
...any object you leave lying around will be destroyed if you don't
tell the jsapi you're still using it.
...the rest of this section
tells how you can control scripts' access to data and functionality.
JSAPI reference
gcharsz added in spidermonkey 1.8.5 obsolete since jsapi 33 js_getstringcharszandlength added in spidermonkey 1.8.5 obsolete since jsapi 33 js_getflatstringchars obsolete since jsapi 33 js_makestringimmutable obsolete since javascript 1.8.5 js_encodecharacters obsolete since jsapi 19 js_cstringsareutf8 obsolete since jsapi 19 js_setcstringsareutf8 obsolete since jsapi 19 interning strings
tells the spidermonkey engine to reuse existing string objects when possible.
...alreadyhasownelement added in spidermonkey 1.8 js_alreadyhasownproperty added in spidermonkey 1.8 js_alreadyhasownucproperty added in spidermonkey 1.8 js_alreadyhasownpropertybyid added in spidermonkey 1.8.1 js_defineproperty js_defineucproperty js_definepropertybyid added in spidermonkey 1.8.1 js_defineproperties js_enumerate js_forwardgetpropertyto added in spidermonkey 17 js_forwardge
telementto added in spidermonkey 17 js_getpropertydescriptor added in spidermonkey 31 js_getpropertydescriptorbyid added in spidermonkey 1.8.1 js_getownpropertydescriptor added in spidermonkey 31 js_getownpropertydescriptorbyid added in spidermonkey 31 js_getownucpropertydescriptor added in spidermonkey 45 js_setallnonreservedslotstoundefined added in spidermonkey 24 js_aliasproperty obsole...
... jsgetmethodop obsolete since javascript 1.8.5 jssetmethodop obsolete since javascript 1.8.5 jsenumeratevaluesop obsolete since javascript 1.8.5 jsconcatenateop obsolete since javascript 1.8.5 arrays js_newarrayobject js_isarrayobject js_getarraylength js_setarraylength js_defineelement js_deleteelement js_ge
telement js_haselement js_se
telement js_hasarraylength obsolete since jsapi 8 js_aliaselement obsolete since jsapi 8 js_lookupelement obsolete since jsapi 37 js_deleteelement2 obsolete since jsapi 39 functions calling a function or a method of an object: class js::callargs added in spidermonkey 17 js::callargsfromvp added in spidermonkey 17 js::call added in spidermonkey 17 js::cons...
Web Replay
the data stream should have enough error checking in place that we can immedia
tely detect if the replay has gone out of sync with the recording.
... these threads idle until the recording/replaying content tries to 'create' them, then they run their main function, and after completing it will idle indefini
tely.
... a simpler way of
telling that a redirection is needed for a function is that the replay tests crash inside it while replaying.
An Overview of XPCOM
in addition to writing well-commented code that
tells the client developer the rules about init(), the developer can take a couple steps to make this contract even clearer.
...in this way, construction and initialization can be comple
tely hidden from clients of the class.
... the example in encapsulating the constructor is a simple and sta
teless version of factories, but real world programming isn't usually so simple, and in general factories need to store state.
Mozilla internal string guide
the 8-bit and 16-bit string classes have comple
tely separate base classes, but share the same apis.
...unfortuna
tely mozilla::result is not versatile enough to be used here.) bulkwrite() returns a mozilla::bulkwritehandle<t>, where t is either char or char16_t.
...fortuna
tely, the getter_copies() function makes this very easy.
Components.utils.exportFunction
es to the argument that are made in the exported function will affect the original object that was passed in: // privileged scope: for example, a content script function changemyname(user) { user.name = "bill"; } exportfunction(changemyname, contentwindow, { defineas: "changemyname" }); // less-privileged scope: for example, a page script var user = {name: "jim"}; var test = document.ge
telementbyid("test"); test.addeventlistener("click", function() { console.log(user.name); // "jim" window.changemyname(user); console.log(user.name); // "bill" }, false); note that this is subject to the normal rules of xrays: for example, an expando property added to a dom node will not be visible in the original object.
...xrays: // privileged scope: for example, a content script function loguser(user) { // console.log(user.getuser()); // error console.log(user.wrappedjsobject.getuser()); // "bill" } exportfunction(loguser, contentwindow, { defineas: "loguser" }); // less-privileged scope: for example, a page script var user = {getuser: function() {return "bill";}} var test = document.ge
telementbyid("test"); test.addeventlistener("click", function() { window.loguser(user); }, false); passing functions as arguments if functions are given as arguments, these are also passed as xrays.
... callbacks into the exported function just works, making the allowcallbacks option redundant: // privileged scope: for example, a content script function loguser(getuser) { console.log(getuser()); // "bill" } exportfunction(loguser, unsafewindow, { defineas: "loguser" }); // less-privileged scope: for example, a page script function getuser() { return "bill"; } var test = document.ge
telementbyid("test"); test.addeventlistener("click", function() { window.loguser(getuser); }, false); cross-origin checking when the exported function is called each argument, including this, is checked to make sure that the caller subsumes that argument.
mozITXTToHTMLConv
last changed in gecko 1.8.1 (firefox 2 / thunderbird 2 / seamonkey 1.1) inherits from nsistreamconverter implemented by @mozilla.org/txttohtmlconv;1 as a service: var ios = components.classes["@mozilla.org/txttohtmlconv;1"] .getservice(components.interfaces.mozitxttohtmlconv); method overview unsigned long ci
televeltxt(in wstring line, out unsigned long loglinestart) void findurlinplaintext(in wstring text, in long alength, in long apos, out long astartpos, out long aendpos) wstring scanhtml(in wstring text, in unsigned long whattodo) wstring scantxt(in wstring text, in unsigned long whattodo) constants conversion control attributes these bits allow you to control the ...
... ci
televeltxt() returns the "cite level" of the specified text; that is, it indicates how many levels of email reply quotes are used, when the text uses "quote" characters (such as ">") at the beginning of the line to indicate cite levels.
... unsigned long ci
televeltxt( in wstring line, out unsigned long loglinestart ); parameters line the original line of text, which may begin with one or more cite characters such as ">".
nsIDOMNSHTMLDocument
e(in domstring commandid); boolean querycommandsupported(in domstring commandid); domstring querycommandtext(in domstring commandid); obsolete since gecko 14.0 domstring querycommandvalue(in domstring commandid); void releaseevents(in long eventflags); void routeevent(in nsidomevent evt); void write(); obsolete since gecko 2.0 void wri
teln(); obsolete since gecko 2.0 attributes attribute type description alinkcolor domstring same as body.alink bgcolor domstring same as body.bgcolor compatmode domstring returns "backcompat" if the document is in quirks mode or "css1compat" if the document is in full standards or almost standards mode.
... embeds nsidomhtmlcollection equivalent to ge
telementsbytagname("embed") read only.
... wri
teln() obsolete since gecko 2.0 (firefox 4 / thunderbird 3.3 / seamonkey 2.1) void wri
teln( [optional] in domstring text ); parameters text the string to write to the document.
nsIEditor
; output methods astring outputtostring(in astring formattype, in unsigned long flags); example: // flags are declared in base/public/nsidocumentencoder.idl // outputselectiononly = 1, outputformatted = 2, // outputraw = 4, outputbodyonly = 8, // outputpreformatted = 16, outputwrap = 32, // outputformatflowed = 64, outputabsolu
telinks = 258, // outputencodew3centities = 256, outputcrlinebreak = 512, // outputlflinebreak = 1024, outputnoscriptcontent = 2048, // outputnoframescontent = 4096, outputnoformattinginpre = 8192, // outputencodebasicentities=16384, outputencodelatin1entities=32768, // outputencodehtmlentities=65536, outputpersistnbsp=131072 editorapi.outputtostring('text/html', 2); editorapi.outputtos...
...ditorobserver(in nsieditorobserver observer);obsolete since gecko 18 void seteditorobserver(in editactionlistener observer); void removeeditorobserver(in nsieditorobserver observer obsolete since gecko 18); void addeditactionlistener(in nsieditactionlistener listener); void removeeditactionlistener(in nsieditactionlistener listener); void adddocumentsta
telistener(in nsidocumentsta
telistener listener); void removedocumentsta
telistener(in nsidocumentsta
telistener listener); debug methods void dumpcontenttree(); void debugdumpcontent() ; void debugunittests(out long outnumtests, out long outnumtestsfailed); [notxpcom] boolean ismodifiablenode(in nsidomnode anode); constants load flags ...
... roo
telement nsidomelement read only.
nsIIDNService
converttodisplayidn() normalizes a hostname into utf-8 format if the hostname is in the idn whi
telist.
... if the hostname isn't in the whi
telist, it's converted into ace format.
...this is useful if you need to normalize a hostname separa
tely from converting it to display format.
nsIJSON
this method accepts slightly more than the exact json syntax; details of extra accepted syntax are delibera
tely not described.
...this method accepts slightly more than the exact json syntax; details of extra accepted syntax are delibera
tely not described.
...this method accepts slightly more than the exact json syntax; details of extra accepted syntax are delibera
tely not described.
nsIProcess
kill() immedia
tely terminates the process represented by the nsiprocess object.
... void run( in boolean blocking, [array, size_is(count)] in string args, in unsigned long count ); parameters blocking if true, this method will block until the process terminates; if false, the method returns immedia
tely.
... void runw( in boolean blocking, [array, size_is(count)] in wstring args, in unsigned long count ); parameters blocking if true, this method will block until the process terminates; if false, the method returns immedia
tely.
nsISeekableStream
inherits from: nsisupports last changed in gecko 1.7 method overview void seek(in long whence, in long long offset); void seteof(); long long
tell(); constants constant value description ns_seek_set 0 specifies that the offset is relative to the start of the stream.
...
tell() this method reports the current offset, in bytes, from the start of the stream.
... long long
tell(); parameters none.
nsISupports proxies
this is defini
tely bad.
...for instance, if you need to not only use an object remo
tely, but also have it created remo
tely, use the second api.
...calls on object created with this flag will return immedia
tely and you will lose all return information.
Using nsIDirectoryService
although you will not customize these locations, you may need to
tell xpcom where its /bin directory is.
...in this case you will also need to
tell the system of the location of dlls that are linked against.
...if you are registering it yourself it is very important to register it immedia
tely after calling ns_initxpcom.
Working with Multiple Versions of Interfaces
unfortuna
tely we compiled this in the latest sdk, and so this magic number happens to be: "244e4c67-a1d3-44f2-9cab-cdaa31b68046" whereas, inside firefox 2, the iid it happens to know about is: "663ca4a8-d219-4000-925d-d8f66406b626".
...fortuna
tely there is a plan of action that we can follow to rectify this.
...since these classes don't use vtables this means i'm probably, no i can be more positive, defini
tely calling the wrong method.
XPIDL
as far as i can
tell, these properties also apply to typedefs.
...an out parameter is essentially an auxiliary return value, although these are modera
tely cumbersome to use from script contexts and should therefore be avoided if reasonable.
...script code callers can ignore the value of array parameter, but implementors must still set the values appropria
tely.
LDAP Support
in such a scenario, it may be hard to
tell which person you really want to send the message to.
...this can be accomplished by setting the following preferences: user_pref("mail.autocomplete.commentcolumn", 2); user_pref("ldap_2.servers.directoryname.autocomplete.commentformat", "[ou]"); the first preference
tells us to use a comment column in the type down (the default value is 0 for no comment), and that the value for the comment is a custom string unique to each directory.
... address book attribute ldap attribute firstname givenname lastname sn lastname surname displayname cn displayname commonname displayname displayname nickname xmozillanickname primaryemail mail secondemail xmozillasecondemail workphone
telephonenumber homephone homephone faxnumber fax faxnumber facsimile
telephonenumber pagernumber pager pagernumber pagerphone cellularnumber mobile cellularnumber cellphone cellularnumber carphone workaddress postofficebox workaddress streetaddress workcity l wo...
Add to iPhoto
if (document.ge
telementbyid("contentareacontextmenu")) { document.ge
telementbyid("contentareacontextmenu").addeventlistener("popupshowing", iphoto.onpopup, false); } responding when the context menu is clicked when the user right-clicks an image, our handler gets called: onpopup: function() { var node = iphoto.getcurrentnode(); var item = document.ge
telementbyid("add-to-iphoto_menuitem"); if (item) { ...
...if this is null or undefined, we immedia
tely return null, indicating there is no node associated with the context menu.
... null, null, null); var appstr = "file:///applications/iphoto.app"; var appstrcf = corefoundation.cfstringcreatewithcharacters(null, appstr, appstr.length); var appurl = corefoundation.cfurlcreatewithstring(null, appstrcf, null); corefoundation.cfrelease(appstrcf); var b = corefoundation.cfurlgetfsref(appurl, ref.address()); if (!b) { var stringsbundle = document.ge
telementbyid("string-bundle"); alert(stringsbundle.getstring('alert_download_error_string')); } else { var array = ctypes.cast(mutablearray, corefoundation.cfarrayref); appservices.lsopenurlswithrole(array, 0, null, appparams.address(), null, 0); } corefoundation.cfrelease(appurl); // clean up corefoundation.cfrelease(array); } appservices.shutdown(); c...
Flash Activation: Browser Comparison - Plugins
this can be done by calling a javascript function when the plugin is activated: function plugincreated() { // we don't need to see the plugin, so hide it by resizing var plugin = document.ge
telementbyid('myplugin'); plugin.height = 0; plugin.width = 0; plugin.callpluginmethod(); } the html, by default, specifies the flash object to be a size that makes it visible, like this: <!-- give the plugin an initial size so it is visible --> <object type="application/x-shockwave-flash" data="myapp.swf" id="myplugin" width="300" height="300"> <param name="callback" value="plugincre...
... using a script callback to determine when a plugin is activated similarly, a site's script shouldn't attempt to script a plugin immedia
tely upon creation.
...html with a callback that calls the javascript function plugincreated(), like this: <object type="application/x-my-plugin" data="somedata.mytype" id="myplugin"> <param name="callback" value="plugincreated()"> </object> the plugincreated() function is then responsible for the setup of your script and any calls back into the plugin that you need to make: function plugincreated() { document.ge
telementbyid('myplugin').callpluginmethod(); } ...
Set a breakpoint - Firefox Developer Tools
continue to here: when stepping through code, this option
tells the debugging to continue execution through to this point.
... other context menu options worth mentioning are: disable breakpoint: turn it off, but don't remove it comple
tely.
...now when execution pauses, you can view relevant variables immedia
tely.
Aggregate view - Firefox Developer Tools
for example, the entry for array
tells us that there are four array objects in the snapshot.
... let's get an allocation trace: open the memory tool check "record call stacks" load https://mdn.github.io/performance-scenarios/dom-allocs/alloc.html take a snapshot select "view/aggregate" select "group by/call stack" you should see something like this: this is
telling us that 93% of the total heap snapshot was allocated in functions called from "alloc.js", line 35 (our initial createtoolbars() call).
... let's see what the example looks like when we select "inverted call stack": now at the top we can immedia
tely see the createtoolbarbutton() call accounting for 89% of the heap usage in our page.
Dominators view - Firefox Developer Tools
dominators tree panel the dominators tree
tells you which objects in the snapshot are retaining the most memory.
...immedia
tely underneath that is an entry for: every gc root node.
... immedia
tely under each gc root, you'll see all the nodes for which this root is the immediate dominator.
Work with animations - Firefox Developer Tools
for example, try clicking on the bar for img#icon's animation: this is
telling us that two properties were modified: filter and transform.
...it doesn't make much sense to try to animate a geometric property and a translation at the same time — the two effects won't be synchronized — so the transform property is delibera
tely not handed over to the compositor to handle.
... the animation inspector will
tell you this — look at it now and you'll see that: the white lightning bolt icon in the bar has been replaced with a grey lightning bolt icon, to indicate that only some of the relevant properties are being optimized by the compositor.
Console messages - Firefox Developer Tools
async stack frames stack traces show stack frames for async functions separa
tely from those for synchronous functions.
... synchronous and asynchronous reflows if a change is made that invalidates the current layout — for example, the browser window is resized or some javascript modifies an element's css — the layout is not recalculated immedia
tely.
...for example, code like this will cause an immediate, synchronous, reflow, when it calls window.getcomputedstyle(thing).height: var thing = document.ge
telementbyid("the-thing"); thing.style.display = "inline-block"; var thingheight = window.getcomputedstyle(thing).height; because of this, it's a good idea to avoid interleaving write and read calls to an element's styles when manipulating the dom, because every time you read back a style that has been invalidated by a previous write call, you force a synchronous reflow.
AudioParam.setTargetAtTime() - Web APIs
if it is less than or equal to audiocontext.currenttime, the parameter will start changing immedia
tely.
...the decay rate as defined by the timeconstant parameter is exponential; therefore the value will never reach target comple
tely, but after each timestep of length timeconstant, the value will have approached target by another 1-e-1≈63.2%1 - e^{-1} \approx 63.2%.
... if you absolu
tely need to reach the target value by a specific time, you can use audioparam.exponentialramptovalueattime().
Using dynamic styling information - Web APIs
<html> <head> <title>simple style example</title> <script type="text/javascript"> function alterstyle(elem) { elem.style.background = 'green'; } function resetstyle(elemid) { elem = document.ge
telementbyid(elemid); elem.style.background = 'white'; } </script> <style type="text/css"> #p1 { border: solid blue 2px; } </style> </head> <body> <!-- passes a reference to the element's object as parameter 'this'.
... more important than the two properties noted here is the use of the style object to set individual style properties on an element: <!doctype html> <html> <head> <title>style property example</title> <link rel="stylesheet" href="example.css" type="text/css"> <script type="text/javascript"> function stilo() { document.ge
telementbyid('d').style.color = 'orange'; } function resetstyle() { document.ge
telementbyid('d').style.color = 'black'; } </script> </head> <body> <div id="d" class="thunder">thunder</div> <button onclick="stilo()">click here to change text color</button> <button onclick="resetstyle()">reset text color</button> </body> </html> the media and type of the style may or ...
... var el = document.ge
telementbyid('some-element'); el.setattribute('style', 'background-color:darkblue;'); be aware, however, that setattribute removes all other style properties that may already have been defined in the element's style object.
CacheStorage.keys() - Web APIs
here we have a whi
telist containing the names of the caches we want to keep (cachewhi
telist).
... we return the keys of the caches in the cachestorage object using keys(), then check each key to see if it is in the whi
telist.
... then.addeventlistener('activate', function(event) { var cachewhi
telist = ['v2']; event.waituntil( caches.keys().then(function(keylist) { return promise.all(keylist.map(function(key) { if (cachewhi
telist.indexof(key) === -1) { return caches.delete(key); } }); }) ); }); specifications specification status comment service workersthe definition of 'cachestorage: keys' in that specification.
CanvasRenderingContext2D.globalAlpha - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.globalalpha = 0.5; ctx.fillstyle = 'blue'; ctx.fillrect(10, 10, 100, 100); ctx.fillstyle = 'red'; ctx.fillrect(50, 50, 100, 100); result overlaying transparent shapes this example illustrates the effect of overlaying multiple transparent shapes on top of each other.
...if we were to increase the step count (and thus draw more circles), the background would eventually disappear comple
tely from the center of the image.
... <canvas id="canvas" width="150" height="150"></canvas> const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // draw background ctx.fillstyle = '#fd0'; ctx.fillrect(0, 0, 75, 75); ctx.fillstyle = '#6c0'; ctx.fillrect(75, 0, 75, 75); ctx.fillstyle = '#09f'; ctx.fillrect(0, 75, 75, 75); ctx.fillstyle = '#f30'; ctx.fillrect(75, 75, 75, 75); ctx.fillstyle = '#fff'; // set transparency value ctx.globalalpha = 0.2; // draw transparent circles for (let i = 0; i < 7; i++) { ctx.beginpath(); ctx.arc(75, 75, 10 + 10 * i, 0, math.pi * 2, true); ctx.fill(); } screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.globalalpha' in that specification.
CanvasRenderingContext2D.lineCap - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(20, 20); ctx.linewidth = 15; ctx.linecap = 'round'; ctx.lineto(100, 100); ctx.stroke(); result comparison of line caps in this example three lines are drawn, each with a different value for the linecap property.
...it's drawn comple
tely flush with the guides.
... <canvas id="canvas" width="150" height="150"></canvas> const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const linecap = ['butt', 'round', 'square']; // draw guides ctx.strokestyle = '#09f'; ctx.beginpath(); ctx.moveto(10, 10); ctx.lineto(140, 10); ctx.moveto(10, 140); ctx.lineto(140, 140); ctx.stroke(); // draw lines ctx.strokestyle = 'black'; for (let i = 0; i < linecap.length; i++) { ctx.linewidth = 15; ctx.linecap = linecap[i]; ctx.beginpath(); ctx.moveto(25 + i * 50, 10); ctx.lineto(25 +...
CanvasRenderingContext2D.setLineDash() - Web APIs
syntax ctx.setlinedash(segments); parameters segments an array of numbers that specify distances to alterna
tely draw a line and a gap (in coordinate space units).
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // dashed line ctx.beginpath(); ctx.setlinedash([5, 15]); ctx.moveto(0, 50); ctx.lineto(300, 50); ctx.stroke(); // solid line ctx.beginpath(); ctx.setlinedash([]); ctx.moveto(0, 100); ctx.lineto(300, 100); ctx.stroke(); result some common patterns this example illustrates a variety of common line dash patterns.
... function drawdashedline(pattern) { ctx.beginpath(); ctx.setlinedash(pattern); ctx.moveto(0, y); ctx.lineto(300, y); ctx.stroke(); y += 20; } const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let y = 15; drawdashedline([]); drawdashedline([1, 1]); drawdashedline([10, 10]); drawdashedline([20, 5]); drawdashedline([15, 3, 3, 3]); drawdashedline([20, 3, 3, 3, 3, 3, 3, 3]); drawdashedline([12, 3, 3]); // equals [12, 3, 3, 12, 3, 3] result specifications specification status comment html living standardthe definition of '...
CanvasRenderingContext2D.shadowColor - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // shadow ctx.shadowcolor = 'red'; ctx.shadowoffsetx = 10; ctx.shadowoffsety = 10; // filled rectangle ctx.fillrect(20, 20, 100, 100); // stroked rectangle ctx.linewidth = 6; ctx.strokerect(170, 20, 100, 100); result shadows on translucent shapes a shadow's opacity is affected by the transparency level of its parent object (even wh...
...en shadowcolor specifies a comple
tely opaque value).
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // shadow ctx.shadowcolor = 'rgba(255, 0, 0, .8)'; ctx.shadowblur = 8; ctx.shadowoffsetx = 30; ctx.shadowoffsety = 20; // filled rectangle ctx.fillstyle = 'rgba(0, 255, 0, .2)'; ctx.fillrect(10, 10, 150, 100); // stroked rectangle ctx.linewidth = 10; ctx.strokestyle = 'rgba(0, 0, 255, .6)'; ctx.strokerect(10, 10, 150, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.shadowc...
CanvasRenderingContext2D.stroke() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.rect(10, 10, 150, 100); ctx.stroke(); result re-stroking paths typically, you'll want to call beginpath() for each new thing you want to stroke.
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // first sub-path ctx.linewidth = 26; ctx.strokestyle = 'orange'; ctx.moveto(20, 20); ctx.lineto(160, 20); ctx.stroke(); // second sub-path ctx.linewidth = 14; ctx.strokestyle = 'green'; ctx.moveto(20, 80); ctx.lineto(220, 80); ctx.stroke(); // third sub-path ctx.linewidth = 4; ctx.strokestyle = 'pink'; ctx.moveto(20, 140); ctx.lineto(280, 140); ctx.stroke(); result...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.linewidth = 16; ctx.strokestyle = 'red'; // stroke on top of fill ctx.beginpath(); ctx.rect(25, 25, 100, 100); ctx.fill(); ctx.stroke(); // fill on top of stroke ctx.beginpath(); ctx.rect(175, 25, 100, 100); ctx.stroke(); ctx.fill(); result specifications specification status comment html living standardthe definition of 'canvasrend...
CanvasRenderingContext2D - Web APIs
basic example to get a canvasrenderingcontext2d instance, you must first have an html <canvas> element to work with: <canvas id="my-house" width="300" height="300"></canvas> to get the canvas' 2d rendering context, call getcontext() on the <canvas> element, supplying '2d' as the argument: const canvas = document.ge
telementbyid('my-house'); const ctx = canvas.getcontext('2d'); with the context in hand, you can draw anything you like.
... this code draws a house: // set line width ctx.linewidth = 10; // wall ctx.strokerect(75, 140, 150, 110); // door ctx.fillrect(130, 190, 40, 60); // roof ctx.beginpath(); ctx.moveto(50, 140); ctx.lineto(150, 60); ctx.lineto(250, 140); ctx.closepath(); ctx.stroke(); the resulting drawing looks like this: reference drawing rectangles there are three methods that immedia
tely draw rectangles to the canvas.
... gradients and patterns canvasrenderingcontext2d.crea
telineargradient() creates a linear gradient along the line given by the coordinates represented by the parameters.
Constraint validation API - Web APIs
you should not rely on it to comple
tely sanitize data received by the server.
... extensions to other interfaces the constraint validation api extends the interfaces for the form-associated elements listed below with a number of new properties and methods (elements that can have a form attribute that indicates their form owner): htmlbuttonelement htmlfieldse
telement htmlinpu
telement htmlobjec
telement htmloutpu
telement htmlselec
telement htmltextareaelement properties validity a read-only property that returns a validitystate object, whose properties represent validation errors for the value of that element.
...elements with the htmlobjec
telement interface are never candidates for constraint validation.
Content Index API - Web APIs
content indexing allows developers to
tell the browser about their specific offline content.
... async function createreadinglist() { // access our service worker registration const registration = await navigator.serviceworker.ready; // get our index entries const entries = await registration.index.getall(); // create a containing element const readinglis
telem = document.createelement('div'); // test for entries if (!array.length) { // if there are no entries, display a message const message = document.createelement('p'); message.innertext = 'you currently have no articles saved for offline reading.' readinglis
telem.append(message); } else { // if entries are present, display in a list of links to the content const ...
...lis
telem = document.createelement('ul'); for (const entry of entries) { const listitem = document.createelement('li'); const anchorelem = document.createelement('a'); anchorelem.innertext = entry.title; anchorelem.setattribute('href', entry.url); lis
telem.append(listitem); } readinglis
telem.append(lis
telem); } } unregistering indexed content below is an asynchronous function, that removes an item from the content index.
Document.createElement() - Web APIs
addelement; function addelement () { // create a new div element const newdiv = document.createelement("div"); // and give it some content const newcontent = document.createtextnode("hi there and greetings!"); // add the text node to the newly created div newdiv.appendchild(newcontent); // add the newly created element and its content into the dom const currentdiv = document.ge
telementbyid("div1"); document.body.insertbefore(newdiv, currentdiv); } web component example the following example snippet is taken from our expanding-list-web-component example (see it live also).
... in this case, our custom element extends the htmlulis
telement, which represents the <ul> element.
... // create a class for the element class expandinglist extends htmlulis
telement { constructor() { // always call super first in constructor super(); // constructor definition left out for brevity ...
Document Object Model (DOM) - Web APIs
transformelement svgcircleelement svgclippathelement svgcolorprofileelement svgcomponenttransferfunctionelement svgcursorelement svgdefselement svgdescelement svgelement svgellipseelement svgfeblendelement svgfecolormatrixelement svgfecomponenttransferelement svgfecompositeelement svgfeconvolvematrixelement svgfediffuselightingelement svgfedisplacementmapelement svgfedistantligh
telement svgfedropshadowelement svgfefloodelement svgfefuncaelement svgfefuncbelement svgfefuncgelement svgfefuncrelement svgfegaussianblurelement svgfeimageelement svgfemergeelement svgfemergenodeelement svgfemorphologyelement svgfeoffse
telement svgfepointligh
telement svgfespecularlightingelement svgfespotligh
telement svgfetileelement svgfeturbulenceelement svgfilterelement svgfil...
...terprimitivestandardattributes svgfon
telement svgfontfaceelement svgfontfaceforma
telement svgfontfacenameelement svgfontfacesrcelement svgfontfaceurielement svgforeignobjec
telement svggelement svggeometryelement svgglyphelement svgglyphrefelement svggradien
telement svggraphicselement svghatchelement svghatchpathelement svghkernelement svgimageelement svglineargradien
telement svglineelement svgmarkerelement svgmaskelement svgmeshelement svgmeshgradien
telement svgmeshpatchelement svgmeshrowelement svgmetadataelement svgmissingglyphelement svgmpathelement svgpathelement svgpatternelement svgpolylineelement svgpolygonelement svgradialgradien
telement svgrec
telement svgscrip
telement svgse
telement svgsolidcolorelement svgstope...
...lement svgstyleelement svgsvgelement svgswitchelement svgsymbolelement svgtextconten
telement svgtex
telement svgtextpathelement svgtextpositioningelement svgtitleelement svgtrefelement svgtspanelement svguseelement svgunknownelement svgviewelement svgvkernelement svg data type interfaces here are the dom apis for data types used in the definitions of svg properties and attributes.
EffectTiming.iterations - Web APIs
the default value is 1, indicating that it should only play once, but you can set it to any floating-point value (including positive infinity defaults to 1, and can also take a value of infinity to make it loop infini
tely.
...any value from 0 (don't play the animation at all) to positive infinity (run the animation indefini
tely) is supported.
... examples in the forgotten key example, alice waves her arm up and down the entire time the page is open by passing infinity as the value for her iterations property: // get alice's arm, and wave it up and down document.ge
telementbyid("alice_arm").animate([ { transform: 'rotate(10deg)' }, { transform: 'rotate(-40deg)' } ], { easing: 'steps(2, end)', iterations: infinity, direction: 'alternate', duration: 600 }); specifications specification status comment web animationsthe definition of 'iterations' in that specification.
Element: compositionend event - Web APIs
bubbles yes cancelable yes interface compositionevent event handler property none examples const inpu
telement = document.queryselector('input[type="text"]'); inpu
telement.addeventlistener('compositionend', (event) => { console.log(`generated characters were: ${event.data}`); }); live example html <div class="control"> <label for="name">on macos, click in the textbox below,<br> then type <kbd>option</kbd> + <kbd>`</kbd>, then <kbd>a</kbd>:</label> <input type="text" id="example" name="examp...
...clear</button> </div> css body { padding: .2rem; display: grid; grid-template-areas: "control log"; } .control { grid-area: control; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button { display: block; } input[type="text"] { margin: .5rem 0; } kbd { border-radius: 3px; padding: 1px 2px 0; border: 1px solid black; } js const inpu
telement = document.queryselector('input[type="text"]'); const log = document.queryselector('.event-log-contents'); const clearlog = document.queryselector('.clear-log'); clearlog.addeventlistener('click', () => { log.textcontent = ''; }); function handleevent(event) { log.textcontent = log.textcontent + `${event.type}: ${event.data}\n`; } inpu
telement.addeventlistener('compositionstart', ...
...handleevent); inpu
telement.addeventlistener('compositionupdate', handleevent); inpu
telement.addeventlistener('compositionend', handleevent); result specifications specification status ui events working draft ...
Element: compositionstart event - Web APIs
bubbles yes cancelable yes interface compositionevent event handler property none examples const inpu
telement = document.queryselector('input[type="text"]'); inpu
telement.addeventlistener('compositionstart', (event) => { console.log(`generated characters were: ${event.data}`); }); live example html <div class="control"> <label for="name">on macos, click in the textbox below,<br> then type <kbd>option</kbd> + <kbd>`</kbd>, then <kbd>a</kbd>:</label> <input type="text" id="example" name="exa...
...clear</button> </div> css body { padding: .2rem; display: grid; grid-template-areas: "control log"; } .control { grid-area: control; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button { display: block; } input[type="text"] { margin: .5rem 0; } kbd { border-radius: 3px; padding: 1px 2px 0; border: 1px solid black; } js const inpu
telement = document.queryselector('input[type="text"]'); const log = document.queryselector('.event-log-contents'); const clearlog = document.queryselector('.clear-log'); clearlog.addeventlistener('click', () => { log.textcontent = ''; }); function handleevent(event) { log.textcontent = log.textcontent + `${event.type}: ${event.data}\n`; } inpu
telement.addeventlistener('compositionstart', ...
...handleevent); inpu
telement.addeventlistener('compositionupdate', handleevent); inpu
telement.addeventlistener('compositionend', handleevent); result specifications specification status ui events working draft ...
Element: compositionupdate event - Web APIs
bubbles yes cancelable yes interface compositionevent event handler property none examples const inpu
telement = document.queryselector('input[type="text"]'); inpu
telement.addeventlistener('compositionupdate', (event) => { console.log(`generated characters were: ${event.data}`); }); live example html <div class="control"> <label for="name">on macos, click in the textbox below,<br> then type <kbd>option</kbd> + <kbd>`</kbd>, then <kbd>a</kbd>:</label> <input type="text" id="example" name="ex...
...clear</button> </div> css body { padding: .2rem; display: grid; grid-template-areas: "control log"; } .control { grid-area: control; } .event-log { grid-area: log; } .event-log-contents { resize: none; } label, button { display: block; } input[type="text"] { margin: .5rem 0; } kbd { border-radius: 3px; padding: 1px 2px 0; border: 1px solid black; } js const inpu
telement = document.queryselector('input[type="text"]'); const log = document.queryselector('.event-log-contents'); const clearlog = document.queryselector('.clear-log'); clearlog.addeventlistener('click', () => { log.textcontent = ''; }); function handleevent(event) { log.textcontent = log.textcontent + `${event.type}: ${event.data}\n`; } inpu
telement.addeventlistener('compositionstart', ...
...handleevent); inpu
telement.addeventlistener('compositionupdate', handleevent); inpu
telement.addeventlistener('compositionend', handleevent); result specifications specification status ui events working draft ...
Element.getBoundingClientRect() - Web APIs
empty border-boxes are comple
tely ignored.
...scripts without access to these properties can use code like this: // for scrollx (((t = document.documen
telement) || (t = document.body.parentnode)) && typeof t.scrollleft == 'number' ?
... t : document.body).scrollleft // for scrolly (((t = document.documen
telement) || (t = document.body.parentnode)) && typeof t.scrolltop == 'number' ?
Element.getClientRects() - Web APIs
function addclientrectsoverlay(elt) { /* absolu
tely position a div over each client rect so that its border width is the same as the rectangle's width.
...*/ var rects = elt.getclientrects(); for (var i = 0; i != rects.length; i++) { var rect = rects[i]; var tablerectdiv = document.createelement('div'); tablerectdiv.style.position = 'absolute'; tablerectdiv.style.border = '1px solid red'; var scrolltop = document.documen
telement.scrolltop || document.body.scrolltop; var scrollleft = document.documen
telement.scrollleft || document.body.scrollleft; tablerectdiv.style.margin = tablerectdiv.style.padding = '0'; tablerectdiv.style.top = (rect.top + scrolltop) + 'px'; tablerectdiv.style.left = (rect.left + scrollleft) + 'px'; // we want rect.width to be the border width, so content width is 2px less.
... tablerectdiv.style.width = (rect.width - 2) + 'px'; tablerectdiv.style.height = (rect.height - 2) + 'px'; document.body.appendchild(tablerectdiv); } } (function() { /* call function addclientrectsoverlay(elt) for all elements with assigned class "withclientrectsoverlay" */ var elt = document.ge
telementsbyclassname('withclientrectsoverlay'); for (var i = 0; i < elt.length; i++) { addclientrectsoverlay(elt[i]); } })(); result specifications specification status comment css object model (cssom) view modulethe definition of 'element.getclientrects()' in that specification.
Element.hasPointerCapture() - Web APIs
syntax targe
telement.haspointercapture(pointerid); parameters pointerid the pointerid of a pointerevent object.
... examples <html> <script> function downhandler(ev) { const el = document.ge
telementbyid("target"); // element 'target' will receive/capture further events el.setpointercapture(ev.pointerid); /* ...
... } } function init() { const el = document.ge
telementbyid("target"); el.onpointerdown = downhandler; } </script> <body onload="init();"> <div id="target">touch this element with a pointer.</div> </body> </html> specifications specification status comment pointer events – level 2the definition of 'haspointercapture()' in that specification.
Element.outerHTML - Web APIs
nomodificationallowederror an attempt was made to set outerhtml on an element which is a direct child of a document, such as document.documen
telement.
... examples getting the value of an element's outerhtml property: html <div id="d"> <p>content</p> <p>further elaborated</p> </div> javascript var d = document.ge
telementbyid("d"); console.log(d.outerhtml); // the string '<div id="d"><p>content</p><p>further elaborated</p></div>' // is written to the console window replacing a node by setting the outerhtml property: html <div id="container"> <div id="d">this is a div.</div> </div> javascript var container = document.ge
telementbyid("container"); var d = document.ge
telementbyid("d"); console.log(container.firstchild.nodename); // logs "div" d.outerhtml = "<p>this paragraph replaced the original div.</p>"; console.log(container.firstchild.nodename); // logs "p" // the #d div is no longer part of the document tree, // the ne...
...for example: var div = document.createelement("div"); div.outerhtml = "<div class=\"test\">test</div>"; console.log(div.outerhtml); // output: "<div></div>" also, while the element will be replaced in the document, the variable whose outerhtml property was set will still hold a reference to the original element: var p = document.ge
telementsbytagname("p")[0]; console.log(p.nodename); // shows: "p" p.outerhtml = "<div>this div replaced a paragraph.</div>"; console.log(p.nodename); // still "p"; the returned value will contain html escaped attributes: var anc = document.createelement("a"); anc.href = "https://developer.mozilla.org?a=b&c=d"; console.log(anc.outerhtml); // output: "<a href='https://developer.mozilla.org?a=b&...
Element.scrollHeight - Web APIs
quisque sit amet
tellus et enim bibendum varius et a orci.
...us: 5px; width: 600px; padding: 5px; border: 2px #7fdf55 solid; } #rules { width: 600px; height: 130px; padding: 5px; border: #2a9f00 solid 2px; border-radius: 5px; } javascript function checkreading () { if (checkreading.read) { return; } checkreading.read = this.scrollheight - this.scrolltop === this.clientheight; document.registration.accept.disabled = document.ge
telementbyid("nextstep").disabled = !checkreading.read; checkreading.noticebox.innerhtml = checkreading.read ?
... "thank you." : "please, scroll and read the following text."; } onload = function () { var otoberead = document.ge
telementbyid("rules"); checkreading.noticebox = document.createelement("span"); document.registration.accept.checked = false; checkreading.noticebox.id = "notice"; otoberead.parentnode.insertbefore(checkreading.noticebox, otoberead); otoberead.parentnode.insertbefore(document.createelement("br"), otoberead); otoberead.onscroll = checkreading; checkreading.call(otoberead); } specifications specification status comment css object model (cssom) view modulethe definition of 'element.scrollheight' in that specification.
Event.preventDefault() - Web APIs
the event interface's preventdefault() method
tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.
...this example demonstrates how to prevent that from happening: javascript document.queryselector("#id-checkbox").addeventlistener("click", function(event) { document.ge
telementbyid("output-box").innerhtml += "sorry!
...first, listen for keypress events: var mytextbox = document.ge
telementbyid('my-textbox'); mytextbox.addeventlistener('keypress', checkname, false); the checkname() function, which looks at the pressed key and decides whether to allow it: function checkname(evt) { var charcode = evt.charcode; if (charcode != 0) { if (charcode < 97 || charcode > 122) { evt.preventdefault(); displaywarning( "please use lowercase letters only." ...
ExtendableEvent.waitUntil() - Web APIs
the extendableevent.waituntil() method
tells the event dispatcher that work is ongoing.
...in service workers, waituntil()
tells the browser that work is ongoing until the promise settles, and it shouldn't terminate the service worker if it wants that work to complete.
...this gives the service worker time to update database schemas and delete outdated caches, so other events can rely on a comple
tely upgraded state.
Using Fetch - Web APIs
a headers object is a simple multi-map of names to values: const content = 'hello world'; const myheaders = new headers(); myheaders.append('content-type', 'text/plain'); myheaders.append('content-length', content.length.tostring()); myheaders.append('x-custom-header', 'processthisimmedia
tely'); the same can be achieved by passing an array of arrays or an object literal to the constructor: const myheaders = new headers({ 'content-type': 'text/plain', 'content-length': content.length.tostring(), 'x-custom-header': 'processthisimmedia
tely' }); the contents can be queried and retrieved: console.log(myheaders.has('content-type')); // true console.log(myheaders.has('set-cookie...
...')); // false myheaders.set('content-type', 'text/html'); myheaders.append('x-custom-header', 'anothervalue'); console.log(myheaders.get('content-length')); // 11 console.log(myheaders.get('x-custom-header')); // ['processthisimmedia
tely', 'anothervalue'] myheaders.delete('x-custom-header'); console.log(myheaders.get('x-custom-header')); // [ ] some of these operations are only useful in serviceworkers, but they provide a much nicer api for manipulating headers.
... request bodies can be set by passing body parameters: const form = new formdata(document.ge
telementbyid('login-form')); fetch('/login', { method: 'post', body: form }); both request and response (and by extension the fetch() function), will try to in
telligently determine the content type.
File and Directory Entries API - Web APIs
only for accessing files which are selected by the user in a file <input> element (see htmlinpu
telement as well) or when a file or directory is provided to the web site or app using drag and drop.
... the htmlinpu
telement.webkitentries property lets you access the filesystemfileentry objects for the currently selected files, but only if they are dragged-and-dropped onto the file chooser (bug 1326031).
... if htmlinpu
telement.webkitdirectory is true, the <input> element is instead a directory picker, and you get filesystemdirectoryentry objects for each selected directory.
GlobalEventHandlers.ondragend - Web APIs
syntax var dragendhandler = targe
telement.ondragend; return value dragendhandler the dragend event handler for element targe
telement.
...data("text", ev.target.id); } function dragover_handler(ev) { console.log("dragover"); // change the target element's border to signify a drag over event // has occurred ev.currenttarget.style.background = "lightblue"; ev.preventdefault(); } function drop_handler(ev) { console.log("drop"); ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragenter_handler(ev) { console.log("dragenter"); // change the source element's background color for enter events ev.currenttarget.style.background = "yellow"; } function dragleave_handler(ev) { console.log("dragleave"); // change the source element's border back to white ev.currenttarget.style.background = "white"; } function dragend_handler(ev) { console.l...
... var el=document.ge
telementbyid("target"); el.style.background = "pink"; } function dragexit_handler(ev) { console.log("dragexit"); // change the source element's border back to green to signify a dragexit event ev.currenttarget.style.background = "green"; } function init() { // set handlers for the source's enter/leave/end/exit events var el=document.ge
telementbyid("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <div> <...
GlobalEventHandlers.ondragenter - Web APIs
syntax var dragenterhandler = targe
telement.ondragenter; return value dragenterhandler the dragenter event handler for element targe
telement.
...data("text", ev.target.id); } function dragover_handler(ev) { console.log("dragover"); // change the target element's border to signify a drag over event // has occurred ev.currenttarget.style.background = "lightblue"; ev.preventdefault(); } function drop_handler(ev) { console.log("drop"); ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragenter_handler(ev) { console.log("dragenter"); // change the source element's background color for enter events ev.currenttarget.style.background = "yellow"; } function dragleave_handler(ev) { console.log("dragleave"); // change the source element's border back to white ev.currenttarget.style.background = "white"; } function dragend_handler(ev) { console.l...
... var el=document.ge
telementbyid("target"); el.style.background = "pink"; } function dragexit_handler(ev) { console.log("dragexit"); // change the source element's border back to green to signify a dragexit event ev.currenttarget.style.background = "green"; } function init() { // set handlers for the source's enter/leave/end/exit events var el=document.ge
telementbyid("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <div> <...
GlobalEventHandlers.ondragexit - Web APIs
syntax var dragexithandler = targe
telement.ondragexit; return value dragexithandler the dragexit event handler for element targe
telement.
...data("text", ev.target.id); } function dragover_handler(ev) { console.log("dragover"); // change the target element's border to signify a drag over event // has occurred ev.currenttarget.style.background = "lightblue"; ev.preventdefault(); } function drop_handler(ev) { console.log("drop"); ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragenter_handler(ev) { console.log("dragenter"); // change the source element's background color for enter events ev.currenttarget.style.background = "yellow"; } function dragleave_handler(ev) { console.log("dragleave"); // change the source element's border back to white ev.currenttarget.style.background = "white"; } function dragend_handler(ev) { console.l...
... var el=document.ge
telementbyid("target"); el.style.background = "pink"; } function dragexit_handler(ev) { console.log("dragexit"); // change the source element's border back to green to signify a dragexit event ev.currenttarget.style.background = "green"; } function init() { // set handlers for the source's enter/leave/end/exit events var el=document.ge
telementbyid("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</code></h1> <div> <...
GlobalEventHandlers.ondragleave - Web APIs
syntax var dragleavehandler = targe
telement.ondragleave; return value dragleavehandler the dragleave event handler for element targe
telement.
...", ev.target.id); } function dragover_handler(ev) { console.log("dragover"); // change the target element's background color to signify a drag over event // has occurred ev.currenttarget.style.background = "lightblue"; ev.preventdefault(); } function drop_handler(ev) { console.log("drop"); ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragenter_handler(ev) { console.log("dragenter"); // change the source element's background color for enter events ev.currenttarget.style.background = "yellow"; } function dragleave_handler(ev) { console.log("dragleave"); // change the source element's background color back to white ev.currenttarget.style.background = "white"; } function dragend_handler(ev) { ...
... var el=document.ge
telementbyid("target"); el.style.background = "pink"; } function dragexit_handler(ev) { console.log("dragexit"); // change the source element's background color back to green to signify a dragexit event ev.currenttarget.style.background = "green"; } function init() { // set handlers for the source's enter/leave/end/exit events var el=document.ge
telementbyid("source"); el.ondragenter = dragenter_handler; el.ondragleave = dragleave_handler; el.ondragend = dragend_handler; el.ondragexit = dragexit_handler; } </script> <body onload="init();"> <h1>examples of <code>ondragenter</code>, <code>ondragleave</code>, <code>ondragend</code>, <code>ondragexit</co...
HTMLCanvasElement.toBlob() - Web APIs
var canvas = document.ge
telementbyid('canvas'); canvas.toblob(function(blob) { var newimg = document.createelement('img'), url = url.createobjecturl(blob); newimg.onload = function() { // no longer need to read the blob so it's revoked url.revokeobjecturl(url); }; newimg.src = url; document.body.appendchild(newimg); }); note that here we're creating a png image; if you add a second parameter to ...
... var canvas = document.ge
telementbyid('canvas'); var d = canvas.width; ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(d / 2, 0); ctx.lineto(d, d); ctx.lineto(0, d); ctx.closepath(); ctx.fillstyle = 'yellow'; ctx.fill(); function blobcallback(iconname) { return function(b) { var a = document.createelement('a'); a.textcontent = 'download'; document.body.appendchild(a); a.style.display = 'block'; ...
... var canvas = document.ge
telementbyid('canvas'); var d = canvas.width; ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(d / 2, 0); ctx.lineto(d, d); ctx.lineto(0, d); ctx.closepath(); ctx.fillstyle = 'yellow'; ctx.fill(); function blobcallback(iconname) { return function(b) { var r = new filereader(); r.onloadend = function () { // r.result contains the arraybuffer.
HTMLImageElement.complete - Web APIs
the read-only htmlimageelement interface's complete attribute is a boolean value which indicates whether or not the image has comple
tely loaded.
... syntax let doneloading = htmlimageelement.complete; value a boolean value which is true if the image has comple
tely loaded; otherwise, the value is false.
... the image is considered comple
tely loaded if any of the following are true: neither the src nor the srcset attribute is specified.
HTMLMediaElement.play() - Web APIs
usage notes although the term "autoplay" is usually thought of as referring to pages that immedia
tely begin playing media upon being loaded, web browsers' autoplay policies also apply to any script-initiated playback of media, including calls to play().
... if the user agent is configured not to allow automatic or script-initiated playback of media, calling play() will cause the returned promise to be immedia
tely rejected with a notallowederror.
... example this example demonstrates how to confirm that playback has begun and how to gracefully handle blocked automatic playback: let videoelem = document.ge
telementbyid("video"); let playbutton = document.ge
telementbyid("playbutton"); playbutton.addeventlistener("click", handleplaybutton, false); playvideo(); async function playvideo() { try { await videoelem.play(); playbutton.classlist.add("playing"); } catch(err) { playbutton.classlist.remove("playing"); } } function handleplaybutton() { if (videoelem.paused) { playvideo();...
HTMLTableElement.insertRow() - Web APIs
to insert the row into a specific <tbody>: let specific_tbody = document.ge
telementbyid(tbody_id); let row = specific_tbody.insertrow(index) note: insertrow() inserts the row directly into the table.
... the row does not need to be appended separa
tely as would be the case if document.createelement() had been used to create the new <tr> element.
... html <table id="my-table"> <tr><td>row 1</td></tr> <tr><td>row 2</td></tr> <tr><td>row 3</td></tr> </table> javascript function addrow(tableid) { // get a reference to the table let tableref = document.ge
telementbyid(tableid); // insert a row at the end of the table let newrow = tableref.insertrow(-1); // insert a cell in the row at index 0 let newcell = newrow.insertcell(0); // append a text node to the cell let newtext = document.createtextnode('new bottom row'); newcell.appendchild(newtext); } // call addrow() with the table's id addrow('my-table'); result specifications ...
HTML Drag and Drop API - Web APIs
res adding the draggable attribute and the ondragstart global event handler, as shown in the following code sample: <script> function dragstart_handler(ev) { // add the target element's id to the data transfer object ev.datatransfer.setdata("text/plain", ev.target.id); } window.addeventlistener('domcontentloaded', () => { // get the element by id const element = document.ge
telementbyid("p1"); // add the ondragstart event listener element.addeventlistener("dragstart", dragstart_handler); }); </script> <p id="p1" draggable="true">this element is draggable.</p> for more information, see: draggable attribute reference drag operations guide define the drag's data the application is free to include any number of data items in a drag operation.
... <script> function dragover_handler(ev) { ev.preventdefault(); ev.datatransfer.dropeffect = "move"; } function drop_handler(ev) { ev.preventdefault(); // get the id of the target and add the moved element to the target's dom const data = ev.datatransfer.getdata("text/plain"); ev.target.appendchild(document.ge
telementbyid(data)); } </script> <p id="target" ondrop="drop_handler(event)" ondragover="dragover_handler(event)">drop zone</p> note that each handler calls preventdefault() to prevent additional event processing for this event (such as touch events or pointer events).
...r.setdata("application/my-app", ev.target.id); ev.datatransfer.dropeffect = "move"; } function dragover_handler(ev) { ev.preventdefault(); ev.datatransfer.dropeffect = "move" } function drop_handler(ev) { ev.preventdefault(); // get the id of the target and add the moved element to the target's dom const data = ev.datatransfer.getdata("application/my-app"); ev.target.appendchild(document.ge
telementbyid(data)); } </script> <p id="p1" draggable="true" ondragstart="dragstart_handler(event)">this element is draggable.</p> <div id="target" ondrop="drop_handler(event)" ondragover="dragover_handler(event)">drop zone</div> for more information, see: performing a drop drag end at the end of a drag operation, the dragend event fires at the source element — the element that was the tar...
Using IndexedDB - Web APIs
the request here was generated with a call to indexeddb.open(), so request.result is an instance of idbdatabase, and you defini
tely want to save that for later.
... the behavior described above is new, and is only available as of the following browser releases: firefox 50, google chrome 31 (approxima
tely).
...actionfailure("invalid key"); return; } key = number(key); deletepublication(key); } }); $('#clear-store-button').click(function(evt) { clearobjectstore(); }); var search_button = $('#search-list-button'); search_button.click(function(evt) { displaypublist(); }); } opendb(); addeventlisteners(); })(); // immedia
tely-invoked function expression (iife) test the online live demo note: window.indexeddb.open() is asynchronous; the method will finish running long before the success event is fired.
Intersection Observer API - Web APIs
one thing the intersection observer api can't
tell you: the exact number of pixels that overlap or specifically which ones they are; however, it covers the much more common use case of "if they intersect by somewhere around n%, i need to do something." intersection observer concepts and usage the intersection observer api allows you to configure a callback that is called: (1) whenever one element, called the target, intersects either the devi...
...id; wrapper.appendchild(document.importnode(template, true)); // set up the observer for this box observeroptions.threshold = thresholdsets[i]; observers[i] = new intersectionobserver(intersectioncallback, observeroptions); observers[i].observe(document.queryselector("#" + boxid)); } // scroll to the starting position document.scrollingelement.scrolltop = wrapper.firs
telementchild.getboundingclientrect().top + window.scrolly; document.scrollingelement.scrollleft = 750; } intersectioncallback = (entries) => { entries.foreach((entry) => { let box = entry.target; let visiblepct = (math.floor(entry.intersectionratio * 100)) + "%"; box.queryselector(".topleft").innerhtml = visiblepct; box.queryselector(".topright").innerhtml = visiblepct; box...
...for a threshold value of 0.0 (default) the callback is called approxima
tely upon transition of the boolean value of isintersecting.
MediaStreamConstraints.audio - Web APIs
this
tells getusermedia() that we require an audio track, but we don't care about any specifics beyond that.
...css content body { font: 14px "open sans", "arial", sans-serif; } audio { margin-top: 20px; border: 1px solid black; width: 160px; } .button { cursor: pointer; width: 160px; border: 1px solid black; font-size: 16px; text-align: center; padding-top: 2px; padding-bottom: 4px; color: white; background-color: darkgreen; } javascript content let audioelement = document.ge
telementbyid("audio"); let logelement = document.ge
telementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.ge
telementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ audio: true }).then(stream => audioelement.srcobject = stream) .catch(err => log(err.name + ": " + err.message)); }, false); here we see ...
...css content body { font: 14px "open sans", "arial", sans-serif; } audio { margin-top: 20px; border: 1px solid black; width: 160px; } .button { cursor: pointer; width: 160px; border: 1px solid black; font-size: 16px; text-align: center; padding-top: 2px; padding-bottom: 4px; color: white; background-color: darkgreen; } javascript content let audioelement = document.ge
telementbyid("audio"); let logelement = document.ge
telementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.ge
telementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ audio: { samplesize: 8, echocancellation: true } }).then(stream => audioelement.srcobject = stream) .catch(err => log(err.
MediaStreamConstraints.video - Web APIs
this
tells getusermedia() that we require a video track, but we don't care about any specifics beyond that.
...d="log"></div> css content body { font: 14px "open sans", "arial", sans-serif; } video { margin-top: 20px; border: 1px solid black; } .button { cursor: pointer; width: 160px; border: 1px solid black; font-size: 16px; text-align: center; padding-top: 2px; padding-bottom: 4px; color: white; background-color: darkgreen; } javascript content let videoelement = document.ge
telementbyid("video"); let logelement = document.ge
telementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.ge
telementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ video: true }).then(stream => videoelement.srcobject = stream) .catch(err => log(err.name + ": " + err.message)); }, false); here we se...
...d="log"></div> css content body { font: 14px "open sans", "arial", sans-serif; } video { margin-top: 20px; border: 1px solid black; } .button { cursor: pointer; width: 160px; border: 1px solid black; font-size: 16px; text-align: center; padding-top: 2px; padding-bottom: 4px; color: white; background-color: darkgreen; } javascript content let videoelement = document.ge
telementbyid("video"); let logelement = document.ge
telementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.ge
telementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ video: { width: 160, height: 120, framerate: 15 } }).then(stream => videoelement.srcobject = stream) .catc...
Node.nextSibling - Web APIs
the node.nextsibling read-only property returns the node immedia
tely following the specified one in their parent's childnodes, or returns null if the specified node is the last child in the parent element.
... element.nex
telementsibling may be used to obtain the next element skipping any whitespace nodes, other between-element text, or comments.
... example <div id="div-1">here is div-1</div> <div id="div-2">here is div-2</div> <script> var el = document.ge
telementbyid('div-1').nextsibling, i = 1; console.group('siblings of div-1:'); while (el) { console.log(i, '.
Node.removeChild() - Web APIs
in the second syntax form, however, there is no oldchild reference kept, so assuming your code has not kept any other reference to the node elsewhere, it will immedia
tely become unusable and irretrievable, and will usually be automatically deleted from memory after a short time.
... examples simple examples given this html: <div id="top"> <div id="nested"></div> </div> to remove a specified element when knowing its parent node: let d = document.ge
telementbyid("top"); let d_nested = document.ge
telementbyid("nested"); let throwawaynode = d.removechild(d_nested); to remove a specified element without having to specify its parent node: let node = document.ge
telementbyid("nested"); if (node.parentnode) { node.parentnode.removechild(node); } to remove all children from an element: let element = document.ge
telementbyid("top"); while (element...
....firstchild) { element.removechild(element.firstchild); } causing a typeerror <!--sample html code--> <div id="top"> </div> <script type="text/javascript"> let top = document.ge
telementbyid("top"); let nested = document.ge
telementbyid("nested"); // throws uncaught typeerror let garbage = top.removechild(nested); </script> causing a notfounderror <!--sample html code--> <div id="top"> <div id="nested"></div> </div> <script type="text/javascript"> let top = document.ge
telementbyid("top"); let nested = document.ge
telementbyid("nested"); // this first call correctly removes the node let garbage = top.removechild(nested); // throws uncaught notfounderror garbage = top.removechild(nested); </script> specifications specification status comment ...
Node.textContent - Web APIs
note: to get all of the text and cdata data for the whole document, one could use document.documen
telement.textcontent.
...you can use textcontent to get the element's text content: let text = document.ge
telementbyid('diva').textcontent; // the text variable is now: 'this is some text!' ...
... or set the element's text content: document.ge
telementbyid('diva').textcontent = 'this text is different!'; // the html for diva is now: // <div id="diva">this text is different!</div> specifications specification status comment domthe definition of 'node.textcontent' in that specification.
NonDocumentTypeChildNode.previousElementSibling - Web APIs
the nondocumenttypechildnode.previouselementsibling read-only property returns the element immedia
tely prior to the specified one in its parent's children list, or null if the specified element is the first one in the list.
... syntax prevnode = elementnodereference.previouselementsibling; example <div id="div-01">here is div-01</div> <div id="div-02">here is div-02</div> <li>this is a list item</li> <li>this is another list item</li> <div id="div-03">here is div-03</div> <script> let el = document.ge
telementbyid('div-03').previouselementsibling; document.write('<p>siblings of div-03</p><ol>'); while (el) { document.write('<li>' + el.nodename + '</li>'); el = el.previouselementsibling; } document.write('</ol>'); </script> this example outputs the following into the page when it loads: siblings of div-03 1.
...div polyfills polyfill for internet explorer 8 this property is unsupported prior to ie9, so the following snippet can be used to add support to ie8: // source: https://github.com/alhadis/snippets/blob/master/js/polyfills/ie8-child-elements.js if(!("previouselementsibling" in document.documen
telement)){ object.defineproperty(element.prototype, "previouselementsibling", { get: function(){ var e = this.previoussibling; while(e && 1 !== e.nodetype) e = e.previoussibling; return e; } }); } polyfill for internet explorer 9+ and safari // source: https://github.com/jserz/js_piece/blob/master/dom/nondocumenttypechildnode/previouselementsibling/previouselementsibling.md (function (arr) { arr.foreach(function (item) { if (...
NonDocumentTypeChildNode - Web APIs
nondocumenttypechildnode.previouselementsibling read only returns the element immedia
tely prior to this node in its parent's children list, or null if there is no element in the list prior to this node.
... nondocumenttypechildnode.nex
telementsibling read only returns the element immedia
tely following this node in its parent's children list, or null if there is no element in the list following this node.
...the previouselementsibling and nex
telementsibling are now defined on the latter.
ParentNode - Web APIs
parentnode.firs
telementchild read only returns the first node which is both a child of this parentnode and is also an element, or null if there is none.
... parentnode.las
telementchild read only returns the last node which is both a child of this parentnode and is an element, or null if there is none.
...the parentnode.firs
telementchild, parentnode.las
telementchild, and parentnode.childelementcount properties are now defined on the latter.
PerformanceResourceTiming.fetchStart - Web APIs
the fetchstart read-only property represents a timestamp immedia
tely before the browser starts to fetch the resource.
... if there are http redirects the property returns the time immedia
tely before the user agent starts to fetch the final resource in the redirection.
... syntax resource.fetchstart; return value a domhighrestimestamp immedia
tely before the browser starts to fetch the resource.
PerformanceResourceTiming.redirectEnd - Web APIs
the redirectend read-only property returns a timestamp immedia
tely after receiving the last byte of the response of the last redirect.
... when fetching a resource, if there are multiple http redirects, and any of the redirects have an origin that is different from the current document, and the timing allow check algorithm passes for each redirected resource, this property returns the time immedia
tely after receiving the last byte of the response of the last redirect; otherwise, zero is returned.
... syntax resource.redirectend; return value a timestamp immedia
tely after receiving the last byte of the response of the last redirect.
RTCConfiguration - Web APIs
otherwise, both the rtp and rtcp candidates are returned, separa
tely.
... "require"
tells the ice agent to gather ice candidates for only rtp, and to multiplex rtcp atop them.
...one obvious benefit to providing your own is identity key continuity—if you use the same certificate for subsequent calls, the remote peer can
tell you're the same caller.
RTCDTMFSender.toneBuffer - Web APIs
dtmf tone characters the digits 0-9 these characters represent the digit keys on a
telephone keypad.
... the letters a-d these characters represent the "a" through "d" keys which are part of the dtmf standard but not included on most
telephones.
... the pound/hash sign ("#") and the asterisk ("*") these correspond to the similarly-labeled keys which are typically on the bottom row of the
telephone keypad.
RTCDTMFToneChangeEvent.RTCDTMFToneChangeEvent() - Web APIs
tone characters the digits 0-9 these characters represent the digit keys on a
telephone keypad.
... the letters a-d these characters represent the "a" through "d" keys which are part of the dtmf standard but not included on most
telephones.
... the pound/hash sign ("#") and the asterisk ("*") these correspond to the similarly-labeled keys which are typically on the bottom row of the
telephone keypad.
RTCPeerConnection.onaddstream - Web APIs
the event is sent immedia
tely after the call setremotedescription() and doesn't wait for the result of the sdp negotiation.
...the first time an event occurs may be nearly immedia
tely after the remote end of the connection is set using rtcpeerconnection.setremotedescription(); it doesn't wait for a particular stream to be accepted or rejected using sdp negotiation.
... pc.onaddstream = function(event) { document.ge
telementbyid("received_video").srcobject = event.stream; document.ge
telementbyid("hangup-button").disabled = false; }; you can also use addeventlistener() to add a handler for addstream events to an rtcpeerconnection.
RTCPeerConnection.setRemoteDescription() - Web APIs
because descriptions will be exchanged until the two peers agree on a configuration, the description submitted by calling setremotedescription() does not immedia
tely take effect.
... function handleoffer(msg) { createmypeerconnection(); mypeerconnection.setremotedescription(msg.description).then(function () { return navigator.mediadevices.getusermedia(mediaconstraints); }) .then(function(stream) { document.ge
telementbyid("local_video").srcobject = stream; return mypeerconnection.addstream(stream); }) .then(function() { return mypeerconnection.createanswer(); }) .then(function(answer) { return mypeerconnection.setlocaldescription(answer); }) .then(function() { // send the answer to the remote peer using the signaling server }) .catch(handlegetusermediaerror); } after creat...
...ing our rtcpeerconnection and saving it as mypeerconnection, we pass the description included in the received offer message, msg, directly into setremotedescription() to
tell the user agent's webrtc layer what configuration the caller has proposed using.
SVGTextPathElement - Web APIs
roke="#d4dde4" stroke-width="2px" /><text x="391" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svggraphicselement</text></a><polyline points="301,89 291,84 291,94 301,89" stroke="#d4dde4" fill="none"/><line x1="291" y1="89" x2="261" y2="89" stroke="#d4dde4"/><a xlink:href="/docs/web/api/svgtextconten
telement" target="_top"><rect x="51" y="65" width="210" height="50" fill="#fff" stroke="#d4dde4" stroke-width="2px" /><text x="156" y="94" font-size="12px" font-family="consolas,monaco,andale mono,monospace" fill="#4d4e53" text-anchor="middle" alignment-baseline="middle">svgtextconten
telement</text></a><polyline points="51,89 41,84 41,94 51,89" stroke="#d4dde4" fill="none"/><line x1="41" y1="89" ...
... properties this interface also inherits properties from its parent interface, svgtextconten
telement, and also implements properties of svgurireference.
... methods this interface does not provide any specific methods, but implements those of its parent, svgtextconten
telement, and also implements methods of svgurireference.
Storage Access API - Web APIs
as an example, federated logins often require access to authentication cookies stored in first-party storage, and will require the user to sign in on each site separa
tely (or comple
tely break) if those cookies are not available.
...design properties unique to firefox are summarized here: if the embedded origin tracker.example has already obtained first-party storage access on the top-level origin foo.example, and the user visits a page from foo.example embedding a page from tracker.example again in less than 30 days, the embedded origin will have storage access immedia
tely when loading.
... if a page from top-level origin foo.example embeds more than one <iframe> from tracker.example, and one of those <iframe>s uses the storage access api in order to obtain storage access successfully, all other iframes from tracker.example on foo.example top-level origins will immedia
tely gain storage access as well, without needing to call requeststorageaccess() separa
tely.
Streams API concepts - Web APIs
when a stream later in the chain is still busy and isn't yet ready to accept more chunks, it sends a signal backwards through the chain to
tell earlier transform streams (or the original source) to slow down delivery as appropriate so that you don't end up with a bottleneck anywhere.
...if it is too low, our readablestream can
tell its underlying source to stop sending data, and we backpressure along the stream chain.
... if later on the consumer again wants to receive data, we can use the pull method in the stream creation to
tell our underlying source to feed our stream with data.
Using readable streams - Web APIs
the first object can contain up to five members, only the first of which is required: start(controller) — a method that is called once, immedia
tely after the readablestream is constructed.
...bytestreams will be covered separa
tely in a future tutorial, as they are somewhat different in purpose and use case to regular (default) streams.
... if you wanted to comple
tely get rid of the stream and discard any enqueued chunks, you'd use readablestream.cancel() or readablestreamdefaultreader.cancel().
Using writable streams - Web APIs
the second object is optional, and allows you to specify a custom queueing strategy to use for your stream, which takes the form of an instance of by
telengthqueuingstrategy or countqueuingstrategy.
... the first object can contain up to four members, all of which are optional: start(controller) — a method that is called once, immedia
tely after the writablestream is constructed.
... when abort is called, any previously enqueued chunks are just thrown away immedia
tely and then the stream is moved to an errored state.
Multi-touch interaction - Web APIs
function set_handlers(name) { // install event handlers for the given element var el=document.ge
telementbyid(name); el.ontouchstart = start_handler; el.ontouchmove = move_handler; // use same handler for touchcancel and touchend el.ontouchcancel = end_handler; el.ontouchend = end_handler; } function init() { set_handlers("target1"); set_handlers("target2"); set_handlers("target3"); set_handlers("target4"); } move/pinch/zoom handler this function provides very basic support for 2-to...
...false : true; } function log(name, ev, printtargetids) { var o = document.ge
telementsbytagname('output')[0]; var s = name + ": touches = " + ev.touches.length + " ; targettouches = " + ev.targettouches.length + " ; changedtouches = " + ev.changedtouches.length; o.innerhtml += s + " "; if (printtargetids) { s = ""; for (var i=0; i < ev.targettouches.length; i++) { s += "...
... id = " + ev.targettouches[i].identifier + " "; } o.innerhtml += s; } } function clearlog(event) { var o = document.ge
telementsbytagname('output')[0]; o.innerhtml = ""; } related topics and resources pointer events ...
VisualViewport - Web APIs
for an <iframe>, visual viewport metrics like visualviewport.width always correspond to layout viewport metrics like document.documen
telement.clientwidth.
... var bottombar = document.ge
telementbyid('bottombar'); var viewport = window.visualviewport; function resizehandler() { if (viewport.scale > 1.3) bottombar.style.display = "none"; else bottombar.style.display = "block"; } window.visualviewport.addeventlistener('resize', resizehandler); simulating position: device-fixed this example, also taken from the visual viewport readme, shows how to use this api to sim...
... var bottombar = document.ge
telementbyid('bottombar'); var viewport = window.visualviewport; function viewporthandler() { var layoutviewport = document.ge
telementbyid('layoutviewport'); // since the bar is position: fixed we need to offset it by the visual // viewport's offset from the layout viewport origin.
A basic 2D WebGL animation example - Web APIs
let uscalingfactor; let uglobalcolor; let urotationvector; let avertexposition; // animation timing let previoustime = 0.0; let degreespersecond = 90.0; initializing the program is handled through a load event handler called startup(): window.addeventlistener("load", startup, false); function startup() { glcanvas = document.ge
telementbyid("glcanvas"); gl = glcanvas.getcontext("webgl"); const shaderset = [ { type: gl.vertex_shader, id: "vertex-shader" }, { type: gl.fragment_shader, id: "fragment-shader" } ]; shaderprogram = buildshaderprogram(shaderset); aspectratio = glcanvas.width/glcanvas.height; currentrotation = [0, 1]; currentscale = [1.0, aspectratio]; vert...
...the usage hint gl.static_draw is specified,
telling webgl that the data will be set only one time and never modified, but will be used repeatedly.
... function compileshader(id, type) { let code = document.ge
telementbyid(id).firstchild.nodevalue; let shader = gl.createshader(type); gl.shadersource(shader, code); gl.compileshader(shader); if (!gl.getshaderparameter(shader, gl.compile_status)) { console.log(`error compiling ${type === gl.vertex_shader ?
Adding 2D content to a WebGL context - Web APIs
mat4.translate(modelviewmatrix, // destination matrix modelviewmatrix, // matrix to translate [-0.0, 0.0, -6.0]); // amount to translate //
tell webgl how to pull out the positions from the position // buffer into the vertexposition attribute.
...e const offset = 0; // how many bytes inside the buffer to start from gl.bindbuffer(gl.array_buffer, buffers.position); gl.vertexattribpointer( programinfo.attriblocations.vertexposition, numcomponents, type, normalize, stride, offset); gl.enablevertexattribarray( programinfo.attriblocations.vertexposition); } //
tell webgl to use our program when drawing gl.useprogram(programinfo.program); // set the shader uniforms gl.uniformmatrix4fv( programinfo.uniformlocations.projectionmatrix, false, projectionmatrix); gl.uniformmatrix4fv( programinfo.uniformlocations.modelviewmatrix, false, modelviewmatrix); { const offset = 0; const vertexcount = 4; gl.dra...
...after that, we bind the square's vertex buffer to the attribute the shader is using for avertexposition and we
tell webgl how to pull the data out of it.
Using DTMF with WebRTC - Web APIs
webrtc currently ignores these payloads; this is because webrtc's dtmf support is primarily intended for use with legacy
telephone services that rely on dtmf tones to perform tasks such as:
teleconferencing systems menu systems voicemail systems entry of credit card or other payment information passcode entry note: while the dtmf is not sent to the remote peer as audio, browsers may choose to play the corresponding tone to the local user as part of their user experience, since users are typically used to hear...
... if you'd like to know more about how this works, read rfc 3550: rtp: a transport protocol for real-time applications and rfc 4733: rtp payload for dtmf digits,
telephony tones, and
telephony signals.
... dialing once the connection is open our design requires that when the connection is established, we immedia
tely send the dtmf string.
Inputs and input sources - Web APIs
generally speaking, the selectstart and selectend events
tell you when you might want to display something to the user indicating that the primary action is going on.
... the select event, on the other hand, is the event that
tells your code that the user has completed the action they want to complete.
...because we are managing the avatar's position as defined by the keyboard and mouse in addition to anything the xr hardware might be doing, we need to maintain that information separa
tely and apply it as a transform before rendering the avatar (or the world from the avatar's point of view).
Using Web Workers - Web APIs
terminating a worker if you need to immedia
tely terminate a running worker from the main thread, you can do so by calling the worker's terminate method: myworker.terminate(); the worker thread is killed immedia
tely.
... listeners[event.data.querymethodlistener].apply(instance, event.data.querymethodarguments); } else { this.defaultlistener.call(instance, event.data); } } } // your custom "queryable" worker var mytask = new queryableworker('my_task.js'); // your custom "listeners" mytask.addlistener('printstuff', function (result) { document.ge
telementbyid('firstlink').parentnode.appendchild(document.createtextnode('the difference is ' + result + '!')); }); mytask.addlistener('doalert', function (time, unit) { alert('worker waited for ' + time + ' ' + unit + ' :-)'); }); </script> </head> <body> <ul> <li><a id="firstlink" href="javascript:mytask.sendquery('getdifference', 5, 3);">what is the difference between 5 an...
... the html code <!doctype html> <html> <head> <meta charset="utf-8" /> <title>test threads fibonacci</title> </head> <body> <div id="result"></div> <script language="javascript"> var worker = new worker('fibonacci.js'); worker.onmessage = function(event) { document.ge
telementbyid('result').textcontent = event.data; dump('got: ' + event.data + '\n'); }; worker.onerror = function(error) { dump('worker error: ' + error.message + '\n'); throw error; }; worker.postmessage('5'); </script> </body> </html> the web page creates a div element with the id result , which gets used to display the result, then spawns the worker.
Worker.prototype.postMessage() - Web APIs
ker, msg:', msg); switch (msg.data.atopic) { case 'do_sendmainarrbuff': sendmainarrbuff(msg.data.abuf) break; default: throw 'no atopic on incoming message to chromeworker'; } } myworker.addeventlistener('message', handlemessagefromworker); // ok lets create the buffer and send it var arrbuf = new arraybuffer(8); console.info('arrbuf.by
telength pre transfer:', arrbuf.by
telength); myworker.postmessage( { atopic: 'do_sendworkerarrbuff', abuf: arrbuf // the array buffer that we passed to the transferrable section 3 lines below }, [ arrbuf // the array buffer we created 9 lines above ] ); console.info('arrbuf.by
telength post transfer:', arrbuf.by
telength); worker code self.onmessage = functi...
...on (msg) { switch (msg.data.atopic) { case 'do_sendworkerarrbuff': sendworkerarrbuff(msg.data.abuf) break; default: throw 'no atopic on incoming message to chromeworker'; } } function sendworkerarrbuff(abuf) { console.info('from worker, pre send back abuf.by
telength:', abuf.by
telength); self.postmessage({atopic:'do_sendmainarrbuff', abuf:abuf}, [abuf]); console.info('from worker, post send back abuf.by
telength:', abuf.by
telength); } output logged arrbuf.by
telength pre transfer: 8 bootstrap.js:40 arrbuf.by
telength post transfer: 0 bootstrap.js:42 from worker, pre send back abuf.by
telength: 8 myworker.js:5:2 incoming message from worke...
...} bootstrap.js:20 got back buf in main thread, abuf.by
telength: 8 bootstrap.js:12 from worker, post send back abuf.by
telength: 0 myworker.js:7:2 by
telength goes to 0 as it is transferred.
WritableStream.WritableStream() - Web APIs
underlyingsink can contain the following: start(controller) optional this is a method, called immedia
tely when the object is constructed.
... note: you could define your own custom queuingstrategy, or use an instance of by
telengthqueuingstrategy or countqueuingstrategy for this object value.
... the promise returned by the sink's write() method (line 40)
tells the writablestream and its writer when to resolve defaultwriter.ready.
Sending and Receiving Binary Data - Web APIs
var oreq = new xmlhttprequest(); oreq.open("get", "/myfile.png", true); oreq.responsetype = "arraybuffer"; oreq.onload = function (oevent) { var arraybuffer = oreq.response; // note: not oreq.responsetext if (arraybuffer) { var bytearray = new uint8array(arraybuffer); for (var i = 0; i < bytearray.by
telength; i++) { // do something with each byte in the array } } }; oreq.send(null); you can also read a binary file as a blob by setting the string "blob" to the responsetype property.
...this
tells the browser not to parse it, and to let the bytes pass through unprocessed.
... var req = new xmlhttprequest(); req.open("post", url, true); // set headers and mime-type appropria
tely req.setrequestheader("content-length", 741); req.sendasbinary(abody); line 4 sets the content-length header to 741, indicating that the data is 741 bytes long.
XRView - Web APIs
it's computed by inverting then transposing the model view matrix: mat4.invert(normalmatrix, modelviewmatrix); mat4.transpose(normalmatrix, normalmatrix);
teleporting an object to programmatically move and/or rotate (often referred to as
teleporting) an object, you need to create a new reference space for that object which applies a transform that encapsulates the desired changes.
... the create
teleporttransform() function returns the transform needed to move and rotate an object whose current situation is described by the reference space refspace to a new position and orientation which is computed using previously recorded mouse and keyboard input data which has generated offsets for yaw, pitch, and position along all three axes.
... vec3.cross(vecx, vecy, cubeorientation); vec3.cross(vecy, cubeorientation, vecx); // now compute the transform that
teleports the object to the // specified point and save a copy of it to display to the user // later; otherwise we probably wouldn't need to save mousematrix // at all.
Using the aria-invalid attribute - Accessibility
the aria-invalid attribute is used to indicate that the value entered into an input field does not conform to the format expected by the application.this may include formats such as email addresses or
telephone numbers.
... <input name="name" id="name" aria-required="true" aria-invalid="false" onblur="checkvalidity('name', ' ', 'invalid name entered (requires both first and last name)');"/> <br /> <input name="email" id="email" aria-required="true" aria-invalid="false" onblur="checkvalidity('email', '@', 'invalid e-mail address');"/> note that it is not necessary to validate the fields immedia
tely on blur; the application could wait until the form is submitted (though this is not necessarily recommended).
... the snippet below shows a very simple validation function, which only checks for the presence of a particular character (in the real world, validation will likely be more sophisticated): function checkvalidity(aid, asearchterm, amsg){ var elem = document.ge
telementbyid(aid); var invalid = (elem.value.indexof(asearchterm) < 0); if (invalid) { elem.setattribute("aria-invalid", "true"); updatealert(amsg); } else { elem.setattribute("aria-invalid", "false"); updatealert(); } } the snippet below shows the alert functions, which add (or remove) the error message: function updatealert(msg) { var oldalert = document.ge
telementbyid("alert"); if (oldalert) { document.body.removechild(oldalert); } if (msg) { var ne...
ARIA Test Cases - Accessibility
when the user changes the state, the new state should be spoken immedia
tely.
... in virtual buffer mode, the slider exists in the virtual buffer as a single entity, and any images or text that create the sliders appearance are not presented to the user separa
tely.
... as expandable items are opened and closed, the state change should be announced immedia
tely.
ARIA: button role - Accessibility
color: white; cursor: default; } [role="button"]:hover, [role="button"]:focus, [role="button"]:active { background-color: white; color: navy; } ul { list-style: none; } javascript function handlecommand(event) { // handles both mouse clicks and keyboard // activate with enter or space // get the new name value from the input element let newnameinput = document.ge
telementbyid('newname'); let name = newnameinput.value; newnameinput.value = ''; // clear the text field newnameinput.focus(); // give the text field focus to enable entering and additional name.
... let list = document.ge
telementbyid('namelist'); list.appendchild(listitem); } } toggle button example in this snippet a <span> element is converted to a toggle button using the button role and the aria-pressed attribute.
...); } function handlebtnkeydown(event) { // check to see if space or enter were pressed if (event.key === " " || event.key === "enter" || event.key === "spacebar") { // "spacebar" for ie11 support // prevent the default action to stop scrolling when space is pressed event.preventdefault(); togglebutton(event.target); } } function togglebutton(element) { var audio = document.ge
telementbyid('audio'); // check to see if the button is pressed var pressed = (element.getattribute("aria-pressed") === "true"); // change aria-pressed to the opposite state element.setattribute("aria-pressed", !pressed); // toggle the play state of the audio file if(pressed) { audio.pause(); } else { audio.play(); } } result accessibility concerns buttons are interacti...
::backdrop - CSS: Cascading Style Sheets
the ::backdrop css pseudo-element is a box the size of the viewport which is rendered immedia
tely beneath any element being presented in full-screen mode.
... when multiple elements have been placed into full-screen mode, the backdrop is drawn immedia
tely beneath the frontmost such element, and on top of the older full-screen elements.
...the ::backdrop pseudo-element makes it possible to obscure, style, or comple
tely hide everything located below the element when it's the topmost one in the top layer.
color-gamut - CSS: Cascading Style Sheets
srgb the output device can support approxima
tely the srgb gamut or more.
... p3 the output device can support approxima
tely the gamut specified by the dci p3 color space or more.
... rec2020 the output device can support approxima
tely the gamut specified by the itu-r recommendation bt.2020 color space or more.
scan - CSS: Cascading Style Sheets
rather, it means the process by which an image is painted onto a
television screen (or other device).
... interlace the device draws odd lines and even lines alterna
tely.
... some
televisions use interlaced scanning.
At-rules - CSS: Cascading Style Sheets
/* general structure */ @identifier (rule); /* example:
tells browser to use utf-8 character set */ @charset "utf-8"; there are several at-rules, designated by their identifiers, each with a different syntax: @charset — defines the character set used by the style sheet.
... @import —
tells the css engine to include an external style sheet.
... @namespace —
tells the css engine that all its content must be considered prefixed with an xml namespace.
CSS Containment - CSS: Cascading Style Sheets
it
tells the browser that the internal layout of the element is totally separate from the rest of the page, and that everything about the element is painted inside its bounds.
...by using contain: layout you can
tell the browser it only needs to check this element — everything inside the element is scoped to that element and does not affect the rest of the page, and the containing box establishes an independent formatting context.
... another advantage is that if the containing box is offscreen, the browser does not need to paint its contained elements — these must also be offscreen as they are contained comple
tely by that box.
Controlling Ratios of Flex Items Along the Main Axis - CSS: Cascading Style Sheets
if you want flexbox to comple
tely ignore the size of the item when doing space distribution then set flex-basis to 0.
... this essentially
tells flexbox that all the space is up for grabs, and to share it out in proportion.
...you don’t usually want your content to disappear comple
tely or for boxes to get smaller than their minimum content, so the above rules make sense in terms of sensible behaviour for content that needs to be shrunk in order to fit into a container.
Mastering Wrapping of Flex Items - CSS: Cascading Style Sheets
as the items can grow, they will expand larger than 160 px in order to fill each row comple
tely.
...the container will need to have a height in order that the items will start wrapping and creating new columns, and items will stretch taller to fill each column comple
tely.
... there is no method in flexbox to
tell items in one row to line up with items in the row above — each flex line acts like a new flex container.
Viewport concepts - CSS: Cascading Style Sheets
if you query the width or height of the window and document in chrome or firefox, you may get: document.documen
telement.clientwidth /* 1200 */ window.innerwidth /* 1200 */ window.outerwidth /* 1200 */ document.documen
telement.clientheight /* 800 */ window.innerheight /* 800 */ window.outerheight /* 900 */ there are several dom properties that can help you query viewport size, and other similar lengths: the document element's element.clientwidth is the inner width of a document in css pixels, including ...
...when zoomed in you may get: document.documen
telement.clientwidth /* 800 */ window.innerwidth /* 800 */ window.outerwidth /* 800 in firefox, 1200 in chrome */ document.documen
telement.clientheight /* 533 */ window.innerheight /* 533 */ window.outerheight /* 596 in firefox, 900 in chrome */ the viewport was originally 1200 x 800 pixels.
...to
tell a mobile browser to use the viewport width instead of the default 980px as the width of the screen, developers can include a viewport meta tag, like the following: <meta name="viewport" content="width=device-width"> the width property controls the size of the viewport.
align-items - CSS: Cascading Style Sheets
aseline alignment */ align-items: baseline; align-items: first baseline; align-items: last baseline; /* overflow alignment (for positional alignment only) */ align-items: safe center; align-items: unsafe center; /* global values */ align-items: inherit; align-items: initial; align-items: unset; values normal the effect of this keyword is dependent of the layout mode we are in: in absolu
tely-positioned layouts, the keyword behaves like start on replaced absolu
tely-positioned boxes, and as stretch on all other absolu
tely-positioned boxes.
... in static position of absolu
tely-positioned layouts, the keyword behaves as stretch.
...option> <option value="safe end">safe end</option> <option value="unsafe end">unsafe end</option> <option value="safe self-end">safe self-end</option> <option value="unsafe self-end">unsafe self-end</option> <option value="safe flex-end">safe flex-end</option> <option value="unsafe flex-end">unsafe flex-end</option> </select> </div> javascript var values = document.ge
telementbyid('values'); var display = document.ge
telementbyid('display'); var container = document.ge
telementbyid('container'); values.addeventlistener('change', function (evt) { container.style.alignitems = evt.target.value; }); display.addeventlistener('change', function (evt) { container.classname = evt.target.value; }); result specifications specification status commen...
align-self - CSS: Cascading Style Sheets
normal the effect of this keyword is dependent of the layout mode we are in: in absolu
tely-positioned layouts, the keyword behaves like start on replaced absolu
tely-positioned boxes, and as stretch on all other absolu
tely-positioned boxes.
... in static position of absolu
tely-positioned layouts, the keyword behaves as stretch.
... formal definition initial valueautoapplies toflex items, grid items, and absolu
tely-positioned boxesinheritednocomputed valueauto computes to itself on absolu
tely-positioned elements, and to the computed value of align-items on the parent (minus any legacy keywords) on all other boxes, or start if the box has no parent.
animation-delay - CSS: Cascading Style Sheets
the animation can start later, immedia
tely from its beginning, or immedia
tely and partway through the animation.
... a negative value causes the animation to begin immedia
tely, but partway through its cycle.
... for example, if you specify -1s as the animation delay time, the animation will begin immedia
tely but will start 1 second into the animation sequence.
<easing-function> - CSS: Cascading Style Sheets
steps( n, <direction> ) steps(2, jump-start) steps(2, start) steps(4, jump-end) steps(4, end) steps(5, jump-none) steps(3, jump-both) steps-start the equivalent of steps(1, jump-start) steps-end the equivalent of steps(1, jump-end) step-start the animation jumps immedia
tely to its final state, where it stays until the end.
...ground-color: blue; background-image: radial-gradient(circle at 10px 10px, rgba(25,255,255,0.8),rgba(25,255,255,0.4)); border-radius: 50%; top: 25px; animation: 1.5s infinite alternate; } @keyframes move-right { from { left: 10%; } to { left: 90%; } } li { display: flex; align-items: center; justify-content: center; margin-bottom: 20px; } javascript const selec
telem = document.queryselector('select'); const startbtn = document.queryselector('button'); const divelem = document.queryselector('div > div'); startbtn.addeventlistener('click', () => { if(startbtn.textcontent === 'start animation') { divelem.style.animationname = 'move-right'; startbtn.textcontent = 'stop animation'; divelem.style.animationtimingfunction = selec
telem.value; } els...
...e { divelem.style.animationname = 'unset'; startbtn.textcontent = 'start animation'; } }); selec
telem.addeventlistener('change', () => { divelem.style.animationtimingfunction = selec
telem.value; }); result cubic-bezier() function examples these cubic bézier curves are valid for use in css: /* the canonical bézier curve with four <number> in the [0,1] range.
font-language-override - CSS: Cascading Style Sheets
/* keyword value */ font-language-override: normal; /* <string> values */ font-language-override: "eng"; /* use english glyphs */ font-language-override: "trk"; /* use turkish glyphs */ /* global values */ font-language-override: initial; font-language-override: inherit; font-language-override: unset; by default, html's lang attribute
tells browsers to display glyphs designed specifically for that language.
... values normal
tells the browser to use font glyphs that are appropriate for the language specified by the lang attribute.
... <string>
tells the browser to use font glyphs that are appropriate for the language specified by the string.
font - CSS: Cascading Style Sheets
line-height must immedia
tely follow font-size, preceded by "/", like this: "16px/3" font-family must be the last value specified.
...setpropcont { margin-bottom: 1em; } .curcss { border: none; border-bottom: 1px solid black; text-align: center; width: 80px; } .mandatory { border-bottom-color: red; } .cf:before, .cf:after { content: " "; display: table; } .cf:after { clear: both; } .tar { width: 40px; text-align: right; } .fontfamily { display: inline-block; } javascript var textareas = document.ge
telementsbyclassname("curcss"), shorttext = "", getcheckedvalue, setcss, getproperties, injectcss; getproperties = function () { shorttext = getcheckedvalue("font_style") + " " + getcheckedvalue("font_variant") + " " + getcheckedvalue("font_weight") + " " + getcheckedvalue("font_size") + getcheckedvalue("line_height") + " " + getcheckedvalue(...
..."font_family"); return shorttext; } getcheckedvalue = function(radio_name) { oradio = document.forms[0].elements[radio_name]; for (var i = 0; i < oradio.length; i++) { if(oradio[i].checked) { var propinput = "input_" + radio_name, curelemname = "input_" + radio_name, curelem = document.ge
telementbyid(curelemname); curelem.value = oradio[i].value; return oradio[i].value; } } } setcss = function () { getproperties(); injectcss(shorttext); } injectcss = function(cssfragment) { old = document.body.ge
telementsbytagname("style"); if (old.length > 1) { old[1].paren
telement.removechild(old[1]); } css = document.createelement("style"); css.innerhtml = ".fontshorthand{font: " + cssfragment + "}"; document.body.appendchild(cs...
justify-items - CSS: Cascading Style Sheets
for absolu
tely-positioned elements, it aligns the items inside their containing block on the inline axis, accounting for the offset values of top, left, bottom, and right.
... values auto the value used is the value of the justify-items property of the parents box, unless the box has no parent, or is absolu
tely positioned, in these cases, auto represents normal.
... in absolu
tely-positioned layouts, the keyword behaved like start on replaced absolu
tely-positioned boxes, and as stretch on all other absolu
tely-positioned boxes.
place-items - CSS: Cascading Style Sheets
ace-items: right normal; /* baseline alignment */ place-items: baseline normal; place-items: first baseline auto; place-items: last baseline normal; place-items: stretch auto; /* global values */ place-items: inherit; place-items: initial; place-items: unset; values auto the value used is the value of the justify-items property of the parents box, unless the box has no parent, or is absolu
tely positioned, in these cases, auto represents normal.
... in absolu
tely-positioned layouts, the keyword behaved like start on replaced absolu
tely-positioned boxes, and as stretch on all other absolu
tely-positioned boxes.
...="left auto">left auto</option> <option value="right normal">right normal</option> <option value="baseline normal">baseline normal</option> <option value="first baseline auto">first baseline auto</option> <option value="last baseline normal">last baseline normal</option> <option value="stretch auto">stretch auto</option> </select> </div> javascript var values = document.ge
telementbyid('values'); var display = document.ge
telementbyid('display'); var container = document.ge
telementbyid('container'); values.addeventlistener('change', function (evt) { container.style.placeitems = evt.target.value; }); display.addeventlistener('change', function (evt) { container.classname = evt.target.value; }); css #container { height:200px; width: 240px; place-items: cen...
place-self - CSS: Cascading Style Sheets
normal the effect of this keyword is dependent of the layout mode we are in: in absolu
tely-positioned layouts, the keyword behaves like start on replaced absolu
tely-positioned boxes, and as stretch on all other absolu
tely-positioned boxes.
... in static position of absolu
tely-positioned layouts, the keyword behaves as stretch.
... formal definition initial valueas each of the properties of the shorthand:align-self: autojustify-self: autoapplies toblock-level boxes, absolu
tely-positioned boxes, and grid itemsinheritednocomputed valueas each of the properties of the shorthand:align-self: auto computes to itself on absolu
tely-positioned elements, and to the computed value of align-items on the parent (minus any legacy keywords) on all other boxes, or start if the box has no parent.
right - CSS: Cascading Style Sheets
syntax /* <length> values */ right: 3px; right: 2.4em; /* <percentage>s of the width of the containing block */ right: 10%; /* keyword value */ right: auto; /* global values */ right: inherit; right: initial; right: unset; values <length> a negative, null, or positive <length> that represents: for absolu
tely positioned elements, the distance to the right edge of the containing block.
... auto specifies that: for absolu
tely positioned elements, the position of the element is based on the left property, while width: auto is treated as a width based on the content; or if left is also auto, the element is positioned where it should horizontally be positioned if it were a static element.
... width of the containing blockcomputed valueif specified as a length, the corresponding absolute length; if specified as a percentage, the specified value; otherwise, autoanimation typea length, percentage or calc(); formal syntax <length> | <percentage> | auto examples absolute and relative positioning using right html <div id="relative">relatively positioned</div> <div id="absolute">absolu
tely positioned</div> css #relative { width: 100px; height: 100px; background-color: #ffc7e4; position: relative; top: 20px; left: 20px; } #absolute { width: 100px; height: 100px; background-color: #ffd7c2; position: absolute; bottom: 10px; right: 20px; } result declaring both left and right when both left and right are declared, the element will stretch to meet bo...
Setting up adaptive streaming media sources - Developer guides
the mpd file
tells the browser where the various pieces of media are located, it also includes meta data such as mimetype and codecs and there are other details such as byte-ranges in there too - it is an xml document and in many cases will be generated for you.
... </adaptationset> </period> </mpd> the mpd file
tells the browser where the various pieces of media are located, it also includes meta data such as mimetype and codecs and there are other details such as byte-ranges in there too.
... note: you can also split out your audio and video streams into separate files, which can then be prioritised and served separa
tely depending on bandwidth.
Creating a cross-browser video player - Developer guides
a number of variables pointing to html elements are required: var videocontainer = document.ge
telementbyid('videocontainer'); var video = document.ge
telementbyid('video'); var videocontrols = document.ge
telementbyid('video-controls'); as mentioned earlier, the browser's default controls now need to be disabled, and the custom controls need to be displayed: // hide the default controls video.controls = false; // display the user defined video controls videocontrols.style.display = 'block';...
... with that done, a variable pointing to each of the buttons is now required: var playpause = document.ge
telementbyid('playpause'); var stop = document.ge
telementbyid('stop'); var mute = document.ge
telementbyid('mute'); var volinc = document.ge
telementbyid('volinc'); var voldec = document.ge
telementbyid('voldec'); var progress = document.ge
telementbyid('progress'); var progressbar = document.ge
telementbyid('progress-bar'); var fullscreen = document.ge
telementbyid('fs'); using these handles, events can now be attached to each of the custom control buttons making them interactive.
... ideally, the correct value of the video's duration attribute is available when the loadedmetadata event is raised, which occurs when the video's metadata has been loaded: video.addeventlistener('loadedmetadata', function() { progress.setattribute('max', video.duration); }); unfortuna
tely in some mobile browsers, when loadedmetadata is raised — if it even is raised — video.duration may not have the correct value, or even any value at all.
Using device orientation with 3D transforms - Developer guides
be applied to those values: the initial alpha value is 180 (device flat on the back, top of the screen pointing 12:00), so the rotatez value should be alpha - 180 the y axis of the screen coordinate system is inverted, such that translatey(100px) moves an element 100px down, so the rotatey value should be -gamma finally, the order of the three different rotations is very important to accura
tely convert an orientation to a 3d rotation: rotatez, then rotatex and then rotatey.
... here's a simple code snippet to sum it up: var elem = document.ge
telementbyid("view3d"); window.addeventlistener("deviceorientation", function(e) { // remember to use vendor-prefixed transform property elem.style.transform = "rotatez(" + ( e.alpha - 180 ) + "deg) " + "rotatex(" + e.beta + "deg) " + "rotatey(" + ( -e.gamma ) + "deg)"; }); orientation compensation compensating the orientation of the device can be useful to create parallax effects or augmented reality.
... this is achieved by inverting the previous order of rotations and negating the alpha value: var elem = document.ge
telementbyid("view3d"); window.addeventlistener("deviceorientation", function(e) { // again, use vendor-prefixed transform property elem.style.transform = "rotatey(" + ( -e.gamma ) + "deg)" + "rotatex(" + e.beta + "deg) " + "rotatez(" + - ( e.alpha - 180 ) + "deg) "; }); rotate3d to orientation should you ever need to convert a rotate3d axis-angle to orientation euler angles, you can use the following algorithm: // convert a rotate3d axis-angle to deviceorientation angles function orient( aa ) { var x = aa.x, y = aa.y, z = aa.z, a = aa.a, c = math.cos( aa.a ), s = math.sin( aa.a ), t = 1 - c, // axis-angle to rotation matr...
Rich-Text Editing in Mozilla - Developer guides
figure 3 : setting up rich-text editing html: <body onload="load()"> javascript: function load(){ getiframedocument("editorwindow").designmode = "on"; } function getiframedocument(aid){ // if contentdocument exists, w3c compliant (mozilla) if (document.ge
telementbyid(aid).contentdocument){ return document.ge
telementbyid(aid).contentdocument; } else { // ie return document.frames[aid].document; } } the example contains a doricheditcommand function that makes it easier to execute commands on the iframe's document and keeps the html code clean.
... figure 4 : executing rich editing commands html: <button onclick="doricheditcommand('bold')" style="font-weight:bold;">b</button> javascript: function doricheditcommand(aname, aarg){ getiframedocument('editorwindow').execcommand(aname,false, aarg); document.ge
telementbyid('editorwindow').contentwindow.focus() } example: a simple but complete rich text editor <!doctype html> <html> <head> <title>rich text editor</title> <script type="text/javascript"> var odoc, sdeftxt; function initdoc() { odoc = document.ge
telementbyid("textbox"); sdeftxt = odoc.innerhtml; if (document.compform.switchmode.checked) { setdocmode(true); } } function formatdoc(sc...
...ick="formatdoc('indent');" src="data:image/gif;base64,r0lgodlhfgawaomiaaaaadljwl9vj1ie35gjuaezxtdv3nha7p///////////////////////////////yh5baeaaagalaaaaaawabyaaaq7emljq704650b/x8gemmpgugwhjnzxodkso5oquogo5khbwwesymqscrdhu9voyk5tm9zspfsr9gsjwiaow==" /> <img class="intlink" title="hyperlink" onclick="var slnk=prompt('write the url here','http:\/\/');if(slnk&&slnk!=''&&slnk!='http://'){formatdoc('crea
telink',slnk)}" src="data:image/gif;base64,r0lgodlhfgawaomkab1chdrly19vj3morpgjuaezxrcztb/i19ha7pv8/f///////////////////////yh5baekaa8alaaaaaawabyaaary8mljq7046827/2byiqvhhg9pegvgiklydeuby/rle4fqf4dcj2aqxaijqdcwqcaebwiioemqbgsafhdagghgi9xghahmnoszgjkjei33uesv2+/4vd4taqa7" /> <img class="intlink" title="cut" onclick="formatdoc('cut');" src="data:image/gif;base64,r0lgodlhfgawaiqsab1chbfnsrjtysjywjljwkx...
Separate sites for mobile and desktop - Developer guides
finally, it also allows for comple
tely different user experiences on desktop and mobile — they’re two different sites, after all!
... the bad unfortuna
tely, this approach is not without its drawbacks.
...this is because you have the option of sending comple
tely separate html, javascript, and css to phones and pcs.
HTML attribute: pattern - HTML: Hypertext Markup Language
the pattern attribute is an attribute of the text,
tel, email, url, password, and search input types.
...user agents may use the title contents during constraint validation to
tell the user that the pattern is not matched.
... examples given the following: <p> <label>enter your phone number in the format (123)456-7890 (<input name="
tel1" type="
tel" pattern="[0-9]{3}" placeholder="###" aria-label="3-digit area code" size="2"/>)- <input name="
tel2" type="
tel" pattern="[0-9]{3}" placeholder="###" aria-label="3-digit prefix" size="2"/> - <input name="
tel3" type="
tel" pattern="[0-9]{4}" placeholder="####" aria-label="4-digit number" size="3"/> </label> </p> here we have 3 sections for a north american phone number with an im...
HTML attribute reference - HTML: Hypertext Markup Language
intrinsicsize <img> this attribute
tells the browser to ignore the actual intrinsic size of the image and pretend it’s the size specified in the attribute.
... loading <img>, <iframe> indicates if the element should be loaded lazily (loading="lazy") or loaded immedia
tely (loading="eager").
...unfortuna
tely, there are no clear rules and the way idl attributes behave in conjunction with their corresponding content attributes depends on the attribute.
<a>: The Anchor element - HTML: Hypertext Markup Language
links are not restricted to http-based urls — they can use any url scheme supported by browsers: sections of a page with fragment urls pieces of media files with media fragments
telephone numbers with
tel: urls email addresses with mailto: urls while web browsers may not support other url schemes, web sites can with registerprotocolhandler() hreflang hints at the human language of the linked url.
... linking to
telephone numbers <a href="
tel:+49.157.0156">+49 157 0156</a> <a href="
tel:+1(555)5309">(555) 5309</a>
tel: link behavior varies with device capabilities: cellular devices autodial the number.
... see rfc 3966 for syntax, additional features, and other details about the
tel: url scheme.
<audio>: The Embed Audio element - HTML: Hypertext Markup Language
it is always useful to include the file's mime type inside the type attribute, as the browser is able to instantly
tell if it can play that file, and not waste time on it if not.
... element (opus) if it is able to play it; if not it falls back to the second (vorbis) and finally back to mp3: <audio controls> <source src="foo.opus" type="audio/ogg; codecs=opus"/> <source src="foo.ogg" type="audio/ogg; codecs=vorbis"/> <source src="foo.mp3" type="audio/mpeg"/> </audio> accessibility concerns audio with spoken dialog should provide both captions and transcripts that accura
tely describe its content.
... if automatic captioning services are used, it is important to review the generated content to ensure it accura
tely represents the source audio.
<dfn>: The Definition element - HTML: Hypertext Markup Language
this can be done by using the <dfn> and <abbr> elements in tandem, like this: html <p>the <dfn><abbr title="hubble space
telescope">hst</abbr></dfn> is among the most productive scientific instruments ever constructed.
... it has been in orbit for over 20 years, scanning the sky and returning data and photographs of unprecedented quality and detail.</p> <p>indeed, the <abbr title="hubble space
telescope">hst</abbr> has arguably done more to advance science than any device ever built.</p> note the <abbr> element nested inside the <dfn>.
... the former establishes that the term is an abbreviation ("hst") and specifies the full term ("hubble space
telescope") in its title attribute.
<input type="checkbox"> - HTML: Hypertext Markup Language
(only the htmlinpu
telement’s checked idl attribute is updated.) note: unlike other input controls, a checkboxes value is only included in the submitted data if the checkbox is currently checked.
...if they are comple
tely unrelated, then you can just deal with them all separa
tely, as shown above.
...this is set using the htmlinpu
telement object's indeterminate property via javascript (it cannot be set using an html attribute): inputinstance.indeterminate = true; a checkbox in the indeterminate state has a horizontal line in the box (it looks somewhat like a hyphen or minus sign) instead of a check/tick in most browsers.
<input type="month"> - HTML: Hypertext Markup Language
you can also get and set the date value in javascript using the htmlinpu
telement.value property, for example: <label for="bday-month">what month were you born in?</label> <input id="bday-month" type="month" name="bday-month" value="2017-06"> var monthcontrol = document.queryselector('input[type="month"]'); monthcontrol.value = '1978-06'; additional attributes in addition to the attributes common to <input> elements, month inputs offer the following attributes: ...
...its value can, however, still be changed from javascript code that directly sets the value of the htmlinpu
telement.value property.
...in order to detect whether the browser supports <input type="month">, we create a new <input> element, try setting its type to month, then immedia
tely check what its type is set to.
<input type="text"> - HTML: Hypertext Markup Language
if the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored comple
tely.
...its value can, however, still be changed by javascript code directly setting the htmlinpu
telement.value property.
...it only specifies approxima
tely how many can be seen at a time.
<input type="url"> - HTML: Hypertext Markup Language
if the specified pattern is not specified or is invalid, no regular expression is applied and this attribute is ignored comple
tely.
...its value can, however, still be changed by javascript code directly setting the htmlinpu
telement.value property.
...it only specifies approxima
tely how many can be seen at a time.
<video>: The Video Embed element - HTML: Hypertext Markup Language
height the height of the video's display area, in css pixels (absolute values only; no percentages.) intrinsicsize this attribute
tells the browser to ignore the actual intrinsic size of the image and pretend it’s the size specified in the attribute.
... accessibility concerns videos should provide both captions and transcripts that accura
tely describe its content (see adding captions and subtitles to html5 video for more information on how to implement these).
... if automatic captioning services are used, it is important to review the generated content to ensure it accura
tely represents the source video.
HTML elements reference - HTML: Hypertext Markup Language
<bdi> the html bidirectional isolate element (<bdi>)
tells the browser's bidirectional algorithm to treat the text it contains in isolation from its surrounding text.
... <template> the html content template (<template>) element is a mechanism for holding html that is not to be rendered immedia
tely when a page is loaded but may be instantiated subsequently during runtime using javascript.
... <tt> the obsolete html
teletype text element (<tt>) creates inline text which is presented using the user agent's default monospace font face.
Preloading content with rel="preload" - HTML: Hypertext Markup Language
using as to specify the type of content to be preloaded allows the browser to: prioritize resource loading more accura
tely.
... you can see an example of this in our video example (see the full source code, and also the live version): <head> <meta charset="utf-8"> <title>video preload example</title> <link rel="preload" href="sin
tel-short.mp4" as="video" type="video/mp4"> <link rel="preload" href="sin
tel-short.webm" as="video" type="video/webm"> </head> <body> <video controls> <source src="sin
tel-short.mp4" type="video/mp4"> <source src="sin
tel-short.webm" type="video/webm"> <p>your browser doesn't support html5 video.
... here is a <a href="sin
tel-short.mp4">link to the video</a> instead.</p> </video> </body> so in this case, browsers that support mp4s will preload and use the mp4, making the video player hopefully smoother/more responsive for users.
Evolution of HTTP - HTTP
a typical flow of requests, all through one single connection is now looking like this: get /docs/glossary/simple_header http/1.1 host: developer.mozilla.org user-agent: mozilla/5.0 (macintosh; in
tel mac os x 10.9; rv:50.0) gecko/20100101 firefox/50.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate, br referer: https://developer.mozilla.org/docs/glossary/simple_header 200 ok connection: keep-alive content-encoding: gzip content-type: text/html; charset=utf-8 date: wed, 20 jul 2016 10:55:30 gmt etag: "547fa...
...7e369ef56031dd3bff2ace9fc0832eb251a" keep-alive: timeout=5, max=1000 last-modified: tue, 19 jul 2016 00:59:33 gmt server: apache transfer-encoding: chunked vary: cookie, accept-encoding (content) get /static/img/header-background.png http/1.1 host: developer.cdn.mozilla.net user-agent: mozilla/5.0 (macintosh; in
tel mac os x 10.9; rv:50.0) gecko/20100101 firefox/50.0 accept: */* accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate, br referer: https://developer.mozilla.org/docs/glossary/simple_header 200 ok age: 9578461 cache-control: public, max-age=315360000 connection: keep-alive content-length: 3077 content-type: image/png date: thu, 31 mar 2016 13:34:46 gmt last-modified: wed, 21 oct 2015 18:27:50 gmt server: apache (image content of 3077 bytes) http/1.1 was first publishe...
...he envisioned a web where people can add and move documents remo
tely, a kind of distributed file system.
Identifying resources on the Web - HTTP
https://developer.mozilla.org https://developer.mozilla.org/docs/learn/ https://developer.mozilla.org/search?q=url any of those urls can be typed into your browser's address bar to
tell it to load the associated page (resource).
...common schemes are: scheme description data data uris file host-specific file names ftp file transfer protocol http/https hyper text transfer protocol (secure) javascript url-embedded javascript code mailto electronic mail address ssh secure shell
tel telephone urn uniform resource names view-source source code of the resource ws/wss (encrypted) websocket connections authority www.example.com is the domain name or authority that governs the namespace.
... examples https://developer.mozilla.org/docs/learn
tel:+1-816-555-1212 git@github.com:mdn/browser-compat-data.git ftp://example.org/resource.txt urn:isbn:9780141036144 mailto:help@supercyberhelpdesk.info specifications specification title rfc 7230, section 2.7: uniform resource identifiers hypertext transfer protocol (http/1.1): message syntax and routing ...
Index - HTTP
7 access-control-allow-credentials cors, http, reference, header the access-control-allow-credentials response header
tells browsers whether to expose the response to frontend javascript code when the request's credentials mode (request.credentials) is "include".
... 84 large-allocation http, http header, non-standard, reference, response header, header the non-standard large-allocation response header
tells the browser that the page being loaded is going to want to perform a large allocation.
... 103 strict-transport-security hsts, http, https, security, header the http strict-transport-security response header (often abbreviated as hsts) lets a web site
tell browsers that it should only be accessed using https, instead of using http.
Strict-Transport-Security - HTTP
the http strict-transport-security response header (often abbreviated as hsts) lets a web site
tell browsers that it should only be accessed using https, instead of using http.
...unfortuna
tely, the access point you're using is actually a hacker's laptop, and they're intercepting your original http request and redirecting you to a clone of your bank's site instead of the real thing.
...should it be necessary to disable strict transport security, setting the max-age to 0 (over a https connection) will immedia
tely expire the strict-transport-security header, allowing access via http.
An overview of HTTP - HTTP
http is sta
teless, but not sessionless http is sta
teless: there is no link between two requests being successively carried out on the same connection.
... this immedia
tely has the prospect of being problematic for users attempting to interact with certain pages coherently, for example, using e-commerce shopping baskets.
... but while the core of http itself is sta
teless, http cookies allow the use of stateful sessions.
JavaScript data types and data structures - JavaScript
unfortuna
tely, when the separator is used in one of the "list" elements, then, the list is broken.
...native implementations of them (including weakmaps) can have look-up performance that is approxima
tely logarithmic to constant time.
...maps and weakmaps make it easy to priva
tely bind data to an object.
Loops and iteration - JavaScript
you can think of a loop as a computerized version of the game where you
tell someone to take x steps in one direction, then y steps in another.
...sical</option> <option>opera</option> </select> </p> <p><input id="btn" type="button" value="how many are selected?" /></p> </form> <script> function howmany(selectobject) { let numberselected = 0; for (let i = 0; i < selectobject.options.length; i++) { if (selectobject.options[i].selected) { numberselected++; } } return numberselected; } let btn = document.ge
telementbyid('btn'); btn.addeventlistener('click', function() { alert('number of options selected: ' + howmany(document.selectform.musictypes)); }); </script> do...while statement the do...while statement repeats until a specified condition evaluates to false.
... when you use break without a label, it terminates the innermost enclosing while, do-while, for, or switch immedia
tely and transfers control to the following statement.
Regular expression syntax cheatsheet - JavaScript
if the multiline flag is set to true, also matches immedia
tely after a line break character.
...if the multiline flag is set to true, also matches immedia
tely before a line break character.
...for example, /e?le?/ matches the "el" in "angel" and the "le" in "angle." if used immedia
tely after any of the quantifiers *, +, ?, or {}, makes the quantifier non-greedy (matching the minimum number of times), as opposed to the default, which is greedy (matching the maximum number of times).
async function - JavaScript
} async function concurrentstart() { console.log('==concurrent start with await=='); const slow = resolveafter2seconds() // starts timer immedia
tely const fast = resolveafter1second() // starts timer immedia
tely // 1.
...this runs 2 seconds after 1., immedia
tely after 2., since fast is already resolved } function concurrentpromise() { console.log('==concurrent start with promise.all==') return promise.all([resolveafter2seconds(), resolveafter1second()]).then((messages) => { console.log(messages[0]) // slow console.log(messages[1]) // fast }) } async function parallel() { console.log('==parallel with await promise.all==') // start 2 "jobs" in parallel and wait for both of them to complete await promise.all([ (async()=>console.log(await resolveafter2seconds()))(), (async()=>console.log(await resolveafter1second()))() ]) } sequentialstart() // af...
... this highlights the subtle difference between return foo; and return await foo; — return foo immedia
tely returns foo and never throws, even if foo is a promise that rejects.
Authoring MathML - MathML
html becomes verbose when your document contains advanced structures like lists or tables but fortuna
tely there are many generators from simple notations, wysiwyg editors and other content management systems to help writing web pages.
... fallback for browsers without mathml support unfortuna
tely, some browsers are not able to render mathml equations or only have a limited support.
...given a foo.tex latex file, you can use these simple commands: latexmlc --dest foo.html foo.tex # generate a html5 document foo.html latexmlc --dest foo.epub foo.tex # generate an epub document foo.epub to handle the case of browsers without mathml support, you can use the --javascript parameter to
tell latexml to include one of the fallback scripts: latexmlc --dest foo.html --javascript=https://fred-wang.github.io/mathml.css/mspace.js foo.tex # add the css fallback latexmlc --dest foo.html --javascript=https://fred-wang.github.io/mathjax.js/mpadded-min.js foo.tex # add the mathjax fallback if your latex document is big, you might want to split it into several small pages rather than pu...
Image file type and format guide - Web media technologies
while other data representations are defined in the specification, they are not widely used and often comple
tely unimplemented.
...svg files are ideal for diagrams, icons, and other images which can be accura
tely drawn at any size.
...these include cmyk, ycbcr, and others, making tiff a good choice for storing images intended for print, film, or
television media.
How to make PWAs re-engageable using Notifications and Push - Progressive web apps (PWAs)
instead of showing the notification immedia
tely though, best practice dictates that we should show the popup when the user requests it by clicking on a button: var button = document.ge
telementbyid("notifications"); button.addeventlistener('click', function(e) { notification.requestpermission().then(function(result) { if(result === 'granted') { randomnotification(); } }); }); this shows a popup using the o...
...*/ }); the data can be retrieved and then shown as a notification to the user immedia
tely.
... fetch('./register', { method: 'post', headers: { 'content-type': 'application/json' }, body: json.stringify({ subscription: subscription }), }); then the globaleventhandlers.onclick function on the subscribe button is defined: document.ge
telementbyid('doit').onclick = function() { const payload = document.ge
telementbyid('notification-payload').value; const delay = document.ge
telementbyid('notification-delay').value; const ttl = document.ge
telementbyid('notification-ttl').value; fetch('./sendnotification', { method: 'post', headers: { 'content-type': 'application/json' }, bo...
Graphic design for responsive sites - Progressive web apps (PWAs)
textual content is not a problem, as text boxes are inna
tely responsive, but the picture starts to get ugly when you start including graphics and complex layouts on your pages — especially when those graphics and layouts need to adapt to different displays!
... programmatic images you should also try to use programmatic/vector graphics as much as possible, as they theoretically scale infini
tely so will still look crisp at high resolutions.
...text is infini
tely scalable on the web, and you can also use css text properties to style your web font icons, such as text-shadow and color.
Structural overview of progressive web apps - Progressive web apps (PWAs)
that way, the next time someone visits the app from the device, the ui loads from the cache immedia
tely and any new content is requested from the server (if it isn’t available in the cache already).
...var entry = template.replace(/pos/g,(i+1)) .replace(/slug/g,games[i].slug) .replace(/name/g,games[i].name) .replace(/author/g,games[i].author) .replace(/twitter/g,games[i].twitter) .replace(/website/g,games[i].website) .replace(/github/g,games[i].github); entry = entry.replace('<a href=\'http:///\'></a>','-'); content += entry; }; document.ge
telementbyid('content').innerhtml = content; then it registers a service worker: if ("serviceworker" in navigator) { navigator.serviceworker.register("/pwa-examples/js13kpwa/sw.js"); } after that, the app adds a handler for clicks on a button whose id is notifications; this handler requests permission to send notifications to the user, then generates and sends a random notification.
... var button = document.ge
telementbyid("notifications"); button.addeventlistener('click', function(e) { notification.requestpermission().then(function(result) { if (result === 'granted') { randomnotification(); } }); }); the randomnotification() function follows, rounding out the last of the code in the file: function randomnotification() { var randomitem = math.floor(math.random()*games.length); var notiftitle = games[randomitem].name; var notifbody = 'created by '+games[randomitem].author+'.'; var notifimg = 'data/img/'+games[randomitem].slug+'.jpg'; var options = { body: notifbody, icon: notifimg } var notif = new notification(notiftitle, options); settimeout(randomnotification, 30000); } the service worker the last file we'll briefly look ...
Content type - SVG: Scalable Vector Graphics
the format of an rgb value in hexadecimal notation is a "#" immedia
tely followed by either three or six hexadecimal characters.
...as defined in css2, a frequency value is a <number> immedia
tely followed by a frequency unit identifier.
... time <time> a time value is a <number> immedia
tely followed by a time unit identifier.
SVG 2 support in Mozilla - SVG: Scalable Vector Graphics
svgexternalresourcesrequired removed never implemented svgelement.viewpor
telement and svgelement.ownersvgelement nullable implementation status unknown svgelement.getpresentationattribute() removed never implemented (prototype removed in bug 921456) svgcolor and svgicccolor removed never implemented svgelement.focus(), svgelement.blur() not implemented (bug 778654) svgelement.tabindex implemented (bug 778654) doc...
... auto value for width and height in <image> implementation status unknown referencing entire document with <use> implementation status unknown lang attribute on <desc> and <title> implemented (bug 721920) css transforms on outermost <svg> not affecting svgsvgelement.currentscale or svgsvgelement.currenttranslate implementation status unknown roo
telement attribute deprecated implementation status unknown svgelementinstance and svgelementinstancelist and corresponding attributes on svguseelement removed implementation status unknown <use> event flow following shadow dom spec.
...loop of a single closed path, effected by the startoffset attribute and text-anchor property implementation status unknown <tref> removed implementation status unknown <altglyph>, <altglyphdef>, <altglyphitem> and <glyphref> removed <altglyph>, <altglyphdef> and <altglyphitem> removed (bug 1260032), <glyphref> never really implemented (bug 1302693) svgtextconten
telement.selectsubstring() deprecated implementation status unknown getcomputedtextlength() not including dx and dy values implementation status unknown text in non-rendered elements not included in addressable characters implementation status unknown unknown elements in text render as unpositioned spans implementation status unknown offset distances of...
Scripting - SVG: Scalable Vector Graphics
function myrect(x,y,w,h,message){ this.message=message this.rect=document.createelementns("http://www.w3.org/2000/svg","rect") this.rect.setattributens(null,"x",x) this.rect.setattributens(null,"y",y) this.rect.setattributens(null,"width",w) this.rect.setattributens(null,"height",h) document.documen
telement.appendchild(this.rect) this.rect.addeventlistener("click",this,false) this.handleevent= function(evt){ switch (evt.type){ case "click": alert(this.message) break; } } } inter-document scripting: referencing embedded svg when using svg within html, adobe's svg viewer 3.0 automatically includes a window property called svgdocument that points to the svg docum...
... the best way to get access to the document representing an svg document is to look at htmliframeelement.contentdocument (if the document is presented in an <iframe>) or htmlobjec
telement.contentdocument (if the document is presented in an <object> element), like this: var svgdoc = document.ge
telementbyid("iframe_element").contentdocument; in addition, the <iframe>, <embed>, and <object> elements offer a method, getsvgdocument(), which returns the xmldocument representing the element's embedded svg or null if the element doesn't represent an svg document.
... you can also use document.ge
telementbyid("svg_elem_name").getsvgdocument(), which gives the same result.
Subresource Integrity - Web security
however, using cdns also comes with a risk, in that if an attacker gains control of a cdn, the attacker can inject arbitrary malicious content into files on the cdn (or replace the files comple
tely) and thus can also potentially attack all sites that fetch files from that cdn.
... using subresource integrity you use the subresource integrity feature by specifying a base64-encoded cryptographic hash of a resource (file) you’re
telling the browser to fetch, in the value of the integrity attribute of any <script> or <link> element.
... subresource integrity with the <script> element you can use the following <script> element to
tell a browser that before executing the https://example.com/example-framework.js script, the browser must first compare the script to the expected hash, and verify that there's a match.
Web security
connection security transport security layer (tls) the transport layer security (tls) protocol is the standard for enabling two networked applications or devices to exchange information priva
tely and robustly.
...typically, it's used to
tell if two requests came from the same browser — keeping a user logged-in, for example.
...this is a way to opt out of mime type sniffing, or, in other words, to say that the mime types are delibera
tely configured.
Using custom elements - Web Components
first of all, we define our element's class, in the same manner as before: class expandinglist extends htmlulis
telement { constructor() { // always call super first in constructor super(); // write element functionality in here ...
...the only real difference here is that our element is extending the htmlulis
telement interface, and not htmlelement.
...some of these libraries are snuggsi ツ, x-tag, slim.js, li
telement, smart, stencil and hyperhtml-element.
Web Components
shadow dom: a set of javascript apis for attaching an encapsulated "shadow" dom tree to an element — which is rendered separa
tely from the main document dom — and controlling associated functionality.
...the associated dom interface is htmlslo
telement.
... the slotchange event fired on an htmlslo
telement instance (<slot> element) when the node(s) contained in that slot change.
Index - XSLT: Extensible Stylesheet Language Transformations
or use a download tool, those usually
tell the mime type.
...this in
telligent structuring is particularly important as more and more data transfers are automated and take place between highly heterogeneous machines linked by a network.
...to prevent a normally xsl:-prefixed literal result element (which should simply be copied as-is to the result tree) from being misunderstood by the processor, it is assigned a temporary namespace which is appropria
tely re-converted back to the xslt namespace in the output tree.
Understanding WebAssembly text format - WebAssembly
the first label inside the parenthesis
tells you what type of node it is, and after that there is a space-separated list of either attributes or child nodes.
... webassembly could add an anyfunc type ("any" because the type could hold functions of any signature), but unfortuna
tely this anyfunc type couldn’t be stored in linear memory for security reasons.
...since webassembly is typechecked, and the funcref can be potentially any function signature, we have to supply the presumed signature of the callee at the callsite, hence we include the $return_i32 type, to
tell the program a function returning an i32 is expected.
Cross-domain Content Scripts - Archive of obsolete content
ame whose content is served from "http://en.m.wikipedia.org/": <!doctype html> <!-- page.html --> <html> <head></head> <body> <iframe id="wikipedia" src="http://en.m.wikipedia.org/"></iframe> </body> </html> the "page-script.js" file locates "today's featured article" and sends its content to "main.js": // page-script.js var iframe = window.document.ge
telementbyid("wikipedia"); var todaysfeaturedarticle = iframe.contentwindow.document.ge
telementbyid("mp-tfa"); self.postmessage(todaysfeaturedarticle.textcontent); for this to work, we need to add the "cross-domain-content" key to "package.json": "permissions": { "cross-domain-content": ["http://en.m.wikipedia.org/"] } the add-on should successfully retrieve the iframe's content.
...panel-script.js var url = "http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/json/500?key=your-api-key"; self.port.on("show", function () { var request = new xmlhttprequest(); request.open("get", url, true); request.onload = function () { var jsonresponse = json.parse(request.responsetext); var summary = getsummary(jsonresponse); var element = document.ge
telementbyid("forecast_summary"); element.textcontent = summary; }; request.send(); }); function getsummary(forecast) { return forecast.regionalfcst.fcstperiods.period[0].paragraph[0].$; } finally, we need to add the "cross-domain-content" key to "package.json": "permissions": { "cross-domain-content": ["http://datapoint.metoffice.gov.uk"] } content permissions and unsafewindow if ...
port - Archive of obsolete content
this example rewrites the content script in the port.removelistener() example so that it uses once(): // content-script.js function getfirstparagraph() { var paras = document.ge
telementsbytagname('p'); console.log(paras[0].textcontent); } self.port.once("get-first-para", getfirstparagraph); removelistener() you can use port.on() to listen for messages.
... // content-script.js function getfirstparagraph() { var paras = document.ge
telementsbytagname('p'); console.log(paras[0].textcontent); self.port.removelistener("get-first-para", getfirstparagraph); } self.port.on("get-first-para", getfirstparagraph); the result is that the paragraph is only logged the first time the button is clicked.
Porting the Library Detector - Archive of obsolete content
the library detector
tells you which javascript frameworks the current web page is using.
...this means we'll need two additional content scripts: one in the widget's context, which listens for icon mouseover events and sends a message to main.js containing the name of the corresponding library: function setlibraryinfo(element) { self.port.emit('setlibraryinfo', element.target.title); } var elements = document.ge
telementsbytagname('img'); for (var i = 0; i < elements.length; i++) { elements[i].addeventlistener('mouseover', setlibraryinfo, false); } one in the panel, which updates the panel's content with the library information: self.on("message", function(libraryinfo) { window.document.body.innerhtml = libraryinfo; }); finally main.js relays the library information from the widget to the pan...
SDK API Lifecycle - Archive of obsolete content
we will avoid breaking backwards compatibility unless absolu
tely necessary.
... all warnings should include links to further information about what to use instead of the deprecated module and when the module will be comple
tely removed.
XUL Migration Guide - Archive of obsolete content
xul windows xul windows are used to define comple
tely new windows to host user interface elements specific to the add-on.
...here's a really simple example add-on that modifies the browser chrome using window/utils: function removeforwardbutton() { var window = require("sdk/window/utils").getmostrecentbrowserwindow(); var forward = window.document.ge
telementbyid('forward-button'); var parent = window.document.ge
telementbyid('urlbar-container'); parent.removechild(forward); } require("sdk/ui/button/action").actionbutton({ id: "remove-forward-button", label: "remove forward button", icon: "./icon-16.png", onclick: removeforwardbutton }); there are more useful examples of this technique in the jetpack wiki's collection of third party...
self - Archive of obsolete content
note that the self module is comple
tely different from the global self object accessible to content scripts, which is used by a content script to communicate with the add-on code.
...this data lives in the add-on's data/ directory, immedia
tely below the package.json file.
content/symbiont - Archive of obsolete content
this may take one of the following values: "start": load content scripts immedia
tely after the document element for the page is inserted into the dom, but before the dom content itself has been loaded "ready": load content scripts once dom content has been loaded, corresponding to the domcontentloaded event "end": load content scripts once all the content (dom, js, css, images) for the page has been loaded, at the time the window.onload event fires this prope...
...this may have one of the following values: "start": load content scripts immedia
tely after the document element for the page is inserted into the dom, but before the dom content itself has been loaded "ready": load content scripts once dom content has been loaded, corresponding to the domcontentloaded event "end": load content scripts once all the content (dom, js, css, images) for the page has been loaded, at the time the window.onload event fires contentscriptoptions read...
remote/parent - Archive of obsolete content
ry current and future process processes.forevery(process => { // ask for the process id process.port.emit("fetchid"); // first argument is always the process, then the message payload process.port.once("id", (process, id) => { console.log("child process is remote:" + process.isremote); console.log("child process id:" + id); }); }); content frame manipulation this demonstrates
telling every current frame to link to a specific anchor element: // remote.js const { frames } = require("sdk/remote/child"); // listeners receive the frame the event was for as the first argument frames.port.on("changelocation", (frame, ref) => { frame.content.location += "#" + ref; }); // main.js const { frames, remoterequire } = require("sdk/remote/parent"); remoterequire("./remote.js", mod...
...the module loads asynchronously but you can start sending messages to the module immedia
tely.
window/utils - Archive of obsolete content
isdocumentloaded(window) check if the given window's document is comple
tely loaded.
... parameters window : nsidomwindow returns boolean: true if the document is comple
tely loaded.
jpmignore - Archive of obsolete content
if your project folder contains a lot of files that aren't necessary for the xpi to run, like documentation, jshint, etc., you can use .jpmignore as a whi
telist instead of a blacklist.
... for example: .* * !/data/** !/lib/** !/locale/** !/node_modules/** !/package.json !/icon.png !/icon64.png !/copying !/bootstrap.js !/install.rdf this would include all editor backup files and similar in the whi
telisted subdirectories, to avoid that you can append another blacklist after the whi
telist.
Overview - Archive of obsolete content
it identifies page elements which are eligible for annotation, highlights them on mouseover, and
tells the main add-on code when the user clicks a highlighted element.
...when the user moves the mouse over an annotated element the matcher
tells the main add-on code, which displays the annotation panel.
Bootstrapped extensions - Archive of obsolete content
you need to look up the relevant application ui elements by their id by calling document.ge
telementbyid(), then manipulate them to inject your ui.
... for example, you can get access to the menu bar in firefox with document.ge
telementbyid("main-menubar").
File I/O - Archive of obsolete content
you can
tell files from folders by calling nsifile.isdirectory() and nsifile.isfile() methods on each entry.
...there might be races between different processes and/or threads, e.g., a file could be immedia
tely created or deleted after you check the existence but before you can perform any other actions such as opening the file for reading or writing.
HTML in XUL for rich tooltips - Archive of obsolete content
var htmltip = { onload: function() { //at any point you can save an html string to a xul attribute for later injection into the tooltip document.ge
telementbyid("htmltip1").setattribute("tooltiphtml", "<font color='red'>red foo</font>") document.ge
telementbyid("htmltip2").setattribute("tooltiphtml", "<font color='green'>green foo</font>") }, onmousetooltip: function(event) { //get the html tooltip string assigned to the element that the mouse is over (which will soon launch the tooltip) var txt = event.target.getattribute("tooltiphtml"); ...
...// get the html div element that is inside the custom xul tooltip var div = document.ge
telementbyid("myhtmltipdiv"); //clear the html div element of any prior shown custom html while(div.firstchild) div.removechild(div.firstchild); //safely convert html string to a simple dom object, stripping it of javascript and more complex tags var injecthtml = components.classes["@mozilla.org/feed-unescapehtml;1"] .getservice(components.interfaces.nsiscriptableunescapehtml) .parsefragment(txt, false, null, div); //attach the dom object to the html div element div.appendchild(injecthtml); } } window.addeventlistener('load', htmltip.onload, false); in the xul overlay, xmlns:html is used to enable html tags to be used inside the xul.
QuerySelector - Archive of obsolete content
selector); }; alert(document.$('label')); // [object xulelement] ]]></script> document.prototype.$ = function (selector) { // only for plain xml return this.queryselector(selector); }; var foo = document.implementation.createdocument('somens', 'foo', null); // create an xml document <foo xmlns="somens"/> var bar = foo.createelementns('somens', 'bar'); // add <bar xmlns="somens"/> foo.documen
telement.appendchild(bar); alert(foo.$('bar').nodename); // gives 'bar' element.prototype.$ = function (selector) { // works for html, xul, and plain xml return this.queryselector(selector); }; html example: <h1><a>test!<a/></h1> <script> element.prototype.$ = function (selector) { return this.queryselector(selector); }; alert(document.ge
telementsbytagname('h1')[0].$('a').nodename); // 'a' ...
... xul example: <hbox><vbox/></hbox> <script type="text/javascript"><![cdata[ element.prototype.$ = function (selector) { return this.queryselector(selector); }; var xulns = 'http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'; alert(document.ge
telementsbytagnamens(xulns, 'hbox')[0].$('vbox').nodename); // vbox ]]></script> xml example: <foo xmlns="somens"><bar/></foo> in document earlier var foo = document.ge
telementsbytagnamens('somens', 'foo')[0]; alert(foo.$('bar')); note that for plain xml, the # 'id' selector will not work with an 'id' attribute (since a such-named attribute need not necessarily be of type id in xml, though it is in html and xul), nor will it work with xml:id.
Tree - Archive of obsolete content
iew = tree.treeboxobject.view; for (var i = 0; i < treeview.rowcount; i++) { if (treeview.iscontainer(i) && treeview.iscontaineropen(i)) treeview.toggleopenstate(i); } getting the text from the selected row assuming the given <tree>: <tree id="my-tree" seltype="single" onselect="ontreeselected()"> use the following javascript: function ontreeselected(){ var tree = document.ge
telementbyid("my-tree"); var cellindex = 0; var celltext = tree.view.getcelltext(tree.currentindex, tree.columns.getcolumnat(cellindex)); alert(celltext); } getting the tree item from the focused row assuming <tree id="my-tree">, you can use the following to get the tree item: var view = document.ge
telementbyid("my-tree").view; var sel = view.selection.currentindex; //returns -1 if the ...
...for example, assuming the given <tree>: <tree id="my-tree" onclick="ontreeclicked(event)"> use the following javascript: function ontreeclicked(event){ var tree = document.ge
telementbyid("my-tree"); var tbo = tree.treeboxobject; // get the row, col and child element at the point var row = { }, col = { }, child = { }; tbo.getcellat(event.clientx, event.clienty, row, col, child); var celltext = tree.view.getcelltext(row.value, col.value); alert(celltext); } getting the selected indices of a multiselect tree var start = {}, end = {}, numranges = tree.view...
Displaying web content in an extension without security issues - Archive of obsolete content
for example, your template document might have this code: <style type="text/css"> #entrytemplate { display: none; } </style> <div id="entrytemplate"> <div class="title"></div> <div class="description"></div> </div> now to insert a new entry in the document you would do the following: var template = doc.ge
telementbyid("entrytemplate"); var entry = template.clonenode(true); entry.removeattribute("id"); entry.ge
telementsbyclassname("title")[0].textcontent = title; entry.ge
telementsbyclassname("description")[0].textcontent = description; template.parentnode.appendchild(entry); the important difference here is that the result will always have the same structure as the template tag.
...instead, nsiscriptableunescapehtml.parsefragment() method should be used that is meant for just that scenario: var target = entry.ge
telementsbyclassname("description")[0]; var fragment = components.classes["@mozilla.org/feed-unescapehtml;1"] .getservice(components.interfaces.nsiscriptableunescapehtml) .parsefragment(description, false, null, target); target.appendchild(fragment); this will add the html code to the specified node — minus all the potentially dangerous content.
Jetpack Processes - Archive of obsolete content
these processes are relatively lightweight, do not have access to xpcom, and can inna
tely do little other than compute.
...to prevent such memory leaks, a process can either invalidate a handle, immedia
tely preventing it from being passed as a message argument, or it can unroot the handle, allowing it to be passed as a message argument until all references to it are removed, at which point it is garbage collected.
Chapter 1: Introduction to Extensions - Archive of obsolete content
the add-ons manager handles the following tasks: safely installs and uninstalls add-ons makes sure add-ons are compatible with the version of firefox you're using manages a whi
telist of sites trusted for installing add-ons helps troubleshoot add-ons by disabling them and offering a safe mode confirms and runs updates provides access to add-ons' settings dialogs provides access to add-ons' support sites development environment amenities initially, there wasn't adequate documentation available, and extension developers were largely left to fend for themselves1; howeve...
... extensions can add comple
tely new features to firefox.
Chapter 3: Introduction to XUL—How to build a more intuitive UI - Archive of obsolete content
figure 2 shows how setting align="center" pack="start" on two elements will result in comple
tely different output with the only difference being the value for orient.
... var item = document.ge
telementbyid('menu-item-custom'); function handlecommandevent(aevent) { alert('ok'); item.removeeventlistener('command', handlecommandevent, false); item.parentnode.removechild(item); } item.addeventlistener('command', handlecommandevent, false); listing 11: additions and deletions using a dynamic event listener special menu items much like input elements in html, menuitem elements can ope...
Adding Events and Commands - Archive of obsolete content
<broadcasterset id="xulschoolhello-broadcasterset"> <broadcaster id="xulschoolhello-online-broadcaster" /> </broadcasterset> these elements are comple
tely invisible, so you can put them anywhere.
... let onlinebroadcaster = document.ge
telementbyid("xulschoolhello-online-broadcaster"); onlinebroadcaster.setattribute("label", "something"); you can also have finer-grained control to this behavior by adding the observes element as a child to your observer node.
Adding menus and submenus - Archive of obsolete content
if your extension involves menus in any way, you should test it on mac os x to make sure everything works adequa
tely.
...for example, you could have a menuitem that
tells you the current time and is updated every second.
Adding windows and dialogs - Archive of obsolete content
you'll see that you can choose from a wide variety of buttons, associate any action you need to them, override their labels, and even add comple
tely customized extra buttons.
...however, there are cases where the dialog contents are generated or expanded dynamically by your code, and you'll need to resize them appropria
tely.
Appendix D: Loading Scripts - Archive of obsolete content
these tags are generally inserted into xul overlay files or other xul documents, after which they are automatically loaded into the context of the xul window in question and executed immedia
tely and synchronously.
...problems can ensue if the script immedia
tely attempts to access dom nodes.
Handling Preferences - Archive of obsolete content
the general philosophy in non-windows systems is that a change in a preference applies immedia
tely.
...the element and its children are comple
tely invisible, and their purpose is to list the preferences to be used in the window/pane.
Intercepting Page Loads - Archive of obsolete content
you can close the tab, redirect the tab to about:blank or another page, or
tell the browser to stop loading this page, but in general you don't want to do this because it will be visible to the user and it will look like a bug.
...they may be useful in case you have most of your application logic in xpcom, or if you absolu
tely need a single point of inspection for loads.
Session store API - Archive of obsolete content
starting in firefox 3.5, notifications are sent after reading session store data and before using it, as well as immedia
tely before writing it back to disk.
...this means that you cannot currently
tell if a tab has been saved or restored.
Using the Stylesheet Service - Archive of obsolete content
in firefox 3, the changes take effect immedia
tely, though some declarations (especially those affecting xul) won't work until a reload.
...@mozilla.org/content/style-sheet-service;1" in components.classes) { if(components.id('{41d979dc-ea03-4235-86ff-1e3c090c5630}') .equals(components.interfaces.nsistylesheetservice)) { // stylesheet service is available, but changes won't apply until reload // (firefox 1.5 and 2 behaviour) } else { // stylesheet service is available and changes will apply immedia
tely // (firefox 3 behaviour) } } else { // stylesheet service is not available (pre-firefox 1.5 behaviour) } ...
Localizing an extension - Archive of obsolete content
we add to refreshinformation() the following code: var stringsbundle = document.ge
telementbyid("string-bundle"); var changestring = stringsbundle.getstring('changestring') + " "; var openstring = stringsbundle.getstring('openstring') + " "; var lowstring = stringsbundle.getstring('lowstring') + " "; var highstring = stringsbundle.getstring('highstring') + " "; var volumestring = stringsbundle.getstring('volumestring') + " "; this code gets a reference to the string bundle el...
...ement we added to stockwatcher2.xul by calling document.ge
telementbyid(), specifying the id "string-bundle".
Visualizing an audio spectrum - Archive of obsolete content
<!doctype html> <html> <head> <title>javascript spectrum example</title> </head> <body> <audio id="audio-element" src="song.ogg" controls="true" style="width: 512px;"> </audio> <div><canvas id="fft" width="512" height="200"></canvas></div> <script> var canvas = document.ge
telementbyid('fft'), ctx = canvas.getcontext('2d'), channels, rate, framebufferlength, fft; function loadedmetadata() { channels = audio.mozchannels; rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; fft = new fft(framebufferlength / channels, rate); } ...
...s before drawing spectrum ctx.clearrect(0,0, canvas.width, canvas.height); for (var i = 0; i < fft.spectrum.length; i++ ) { // multiply spectrum by a zoom value magnitude = fft.spectrum[i] * 4000; // draw rectangle bars for each frequency bin ctx.fillrect(i * 4, canvas.height, 3, -magnitude); } } var audio = document.ge
telementbyid('audio-element'); audio.addeventlistener('mozaudioavailable', audioavailable, false); audio.addeventlistener('loadedmetadata', loadedmetadata, false); // fft from dsp.js, see below var fft = function(buffersize, samplerate) { this.buffersize = buffersize; this.samplerate = samplerate; this.spectrum = new float32array(buffersize/2);...
Working with BFCache - Archive of obsolete content
the pagehide event
tells you whether the page is going into bfcache; the pageshow
tells you whether it's coming from bfcache.
...q: hmm, so what event
tells me “you'll never get a pageshow so you can drop the megabytes of info you've saved in firebug side table for that page?” a: an observer notification with the topic "inner-window-destroyed" whose subject is an nsisupportspruint64 containing the window id of the inner window being destroyed.
ActiveX Control for Hosting Netscape Plug-ins in IE - Archive of obsolete content
the sections below
tell you how to fetch, build and use the pluginhostctrl.dll .
... usage insert some html like this into your content: <object classid="clsid:dbb2de32-61f1-4f7f-beb8-a37f5bc24ee2" width="500" height="300"> <param name="type" value="video/quicktime"/> <param name="src" value="http://www.foobar.com/some_movie.mov"/> <!-- custom arguments --> <param name="loop" value="true"/> </object> the classid attribute
tells ie to create an instance of the plug-in hosting control, the width and height specify the dimensions in pixels.
FAQ - Archive of obsolete content
unfortuna
tely, yes.
...if a message appears in the preferences window
telling you that it's an old skin, you're going to have to look over the code to see what changed.
Getting Started - Archive of obsolete content
css files the css files in these directories
tell the browser how to display the buttons and other controls, where to put the images, what border and padding it should put around them, etc.
...<rdf:li resource="urn:mozilla:skin:myskin/1.0:communicator"/> <rdf:li resource="urn:mozilla:skin:myskin/1.0:editor"/> <rdf:li resource="urn:mozilla:skin:myskin/1.0:global"/> <rdf:li resource="urn:mozilla:skin:myskin/1.0:messenger"/> <rdf:li resource="urn:mozilla:skin:myskin/1.0:navigator"/> finally, in the last section of the contents.rdf file we need to
tell mozilla what version this skin is compliant with.
In-Depth - Archive of obsolete content
the image that is listed there by default (chrome://navigator/skin/icons/btn1.gif) is actually a bunch of images grouped together in one file, so somewhere one of the css attributes is
telling it what portion of the larger image to cut out and display.
...organizing images to organize all of your icons you can store them all in one image and then
tell mozilla which portions to use.
Block and Line Layout Cheat Sheet - Archive of obsolete content
this is set by default for document, table cell inner, and absolu
tely positioned wrapper frames.
...this is set by default for document frames, area frames, table cell inner frames, absolu
tely positioned wrapper frames, and floated frames when the frame is created.
Layout System Overview - Archive of obsolete content
in the case of the wysiwyg html editor, the user expects that the modifications they make to the document will appear immedia
tely, not seconds later.
...frame construction is generally achieved by the use of sta
teless methods, but in some cases there is the need to provide context to frames created as children of a container.
JavaScript crypto - Archive of obsolete content
to enable your document to receive these events, you must first
tell the crypto system you are interested by setting window.crypto.enablesmartcardevents to true.
...in fortezza cards pkcs11_mech_rc5_flag = 0x1<<7; pkcs11_mech_sha1_flag = 0x1<<8; pkcs11_mech_md5_flag = 0x1<<9; pkcs11_mech_md2_flag = 0x1<<10; pkcs11_mech_random_flag = 0x1<<27; //random number generator pkcs11_pub_readable_cert_flag = 0x1<<28; //stored certs can be read off the token w/o logging in pkcs11_disable_flag = 0x1<<30; //
tell mozilla to disable this slot by default cipher flags reserved important for cryptomechanismflags 0x1<<11, 0x1<<12, ...
Monitoring downloads - Archive of obsolete content
onload: function() { // initialization code this.initialized = true; this.strings = document.ge
telementbyid("downloadlogger-strings"); this.dlmgr = components.classes["@mozilla.org/download-manager;1"] .getservice(components.interfaces.nsidownloadmanager); this.dlmgr.addlistener(downloadlogger); // open the database, placing its file in the profile directory this.dbfile = components.classes["@mozilla.org/file/directory_service;1"] .
...rofd", components.interfaces.nsifile); this.dbfile.append("downloadlogger.sqlite"); // get access to the storage service and open the database this.storageservice = components.classes["@mozilla.org/storage/service;1"] .getservice(components.interfaces.mozistorageservice); var dbconn = this.storageservice.opendatabase(this.dbfile); var loglist = document.ge
telementbyid("loglist"); var statement = dbconn.createstatement("select * from items"); // get all items in table try { while (statement.executestep()) { var row = document.createelement('listitem'); // add the cells to the row var cell = document.createelement('listcell'); var sourcestr = statement.getstring(0); row.setattribute("tooltiptext", sourc...
RDF Datasource How-To - Archive of obsolete content
more concre
tely, a datasource is a translator that can present information as a collection of rdf statements.
...the first question that you must answer is "should i use an existing vocabulary, or invent my own?" a reasonable answer is, "use an existing vocabulary unless you absolu
tely must invent your own." this will allow your datasource to be integrated with other datasources with a minimum of effort.
Remote XUL - Archive of obsolete content
however, there is a whi
telist that lets you specify sites that can still use remote xul.
... the remote xul manager extension lets you manage this whi
telist, which is maintained using nsipermissionmanager, by creating entries of type "allowxulxbl", like this: components.classes["@mozilla.org/permissionmanager;1"] .getservice(components.interfaces.nsipermissionmanager) .add(uri, 'allowxulxbl', components.interfaces.nsipermissionmanager.allow_action); see using remote xul.
Frequently Asked Questions - Archive of obsolete content
when servers send user agents an svg file they must
tell the user agent that the file has the mime type "image/svg+xml", and if the svg file is stored gzipped they must
tell the browser that too.
...this is either because your browser doesn't support svg (you must have mozilla firefox 1.5 or newer), or because the webpage/server isn't correctly
telling mozilla that the file contains svg.
The life of an HTML HTTP request - Archive of obsolete content
the webshell then
tells its documentloader to load (command "view") the specified url.
...the content sink
tells the document about content model changes (notifybody()) in places like nshtmlcontentsink::willinterrupt() and nshtmlcontentsink::didbuildmodel().
Anonymous Content - Archive of obsolete content
dom methods that can be invoked on elements (e.g., ge
telementsbytagname) will only see nodes that are in the same scope.
... methods invoked on the document (e.g., ge
telementbyid) only see nodes that are at the document-level scope.
Binding Attachment and Detachment - Archive of obsolete content
var checkbox = document.ge
telementbyid("mycheckbox"); checkbox.style.mozbinding = "url(http://www.mozilla.org/xbl/htmlbindings.xml#checkbox)"; this attachment is not necessarily synchronous.
... scripts that invoke this method should not assume that the binding is installed immedia
tely after this method returns.
Creating XPI Installer Modules - Archive of obsolete content
since we are not updating the mozilla ui to provide special access to this window (e.g., an item in the tasks menu or elsewhere), the measure of the success of the installation of the barley package is that the user can, as before, invoke our software by using a special startup option: mozilla -chrome chrome://barley/content this option
tells mozilla to load a chrome other than the default, which is the main browser window.
...for a xpi file to be valid and installable, it must contain an installation script like the one above that
tells mozilla xpinstall where to put the new resources and how to register them.
A XUL Bestiary - Archive of obsolete content
there are, unfortuna
tely, different document object models corresponding to different types of documents and also to different proprietary notions about what in a document should be exposed programmatically.
...in fact, i'm not sure i understand them adequa
tely myself, but here goes a simple explanation of events and of how they are used, basically, in a event-based interface like those created in xul.
id - Archive of obsolete content
you can use this as a parameter to ge
telementbyid() and other dom functions and to reference the element in style sheets.
... example <button id="foo" label="click me" oncommand="dosomething()"/> <script> function dosomething(){ var mybutton = document.ge
telementbyid('foo'); mybutton.setattribute('label','the button was pressed'); } </script> a more abstract version of the above would be a <button id="foo" label="click me" oncommand="setwidgetlabel(this, 'i was pressed')"/> <script> function setwidgetlabel(idname, newcaption){ document.ge
telementbyid( idname.id ).setattribute('label',newcaption) } </script> not specifying the id attribute for a window or a prefwindow fills the console with the following warning message: warning: empty string passed to ge
telementbyid() see also name ...
label - Archive of obsolete content
see also treeitem.label, <label> element examples in javascript <label value="whaw" id="the-big-label" command="the-big-button"/> <button id="the-big-button" label="click me" oncommand="alert(document.ge
telementbyid('the-big-label').value)"/> <label id="mylabel" value="my label"/> <button label="click me" oncommand="document.ge
telementbyid('mylabel').setattribute('value','value changed');" /> <checkbox label="my checkbox" id="mycheckbox"/> <button label="another click" oncommand="document.ge
telementbyid('mycheckbox').setattribute('label','still not checked');"/> <button label="show label of chec...
...kbox" oncommand="alert( document.ge
telementbyid('mycheckbox').getattribute('label') )"/> ...
Methods - Archive of obsolete content
« xul reference home acceptdialog additemtoselection addpane addprogresslistener addsession addtab addtabsprogresslistener advance advanceselectedtab appendcustomtoolbar appendgroup appenditem appendnotification blur cancel canceldialog centerwindowonscreen checkadjacen
telement clearresults clearselection click close collapsetoolbar contains decrease decreasepage docommand ensureelementisvisible ensureindexisvisible ensureselectedelementisvisible expandtoolbar extra1 extra2 focus getbrowseratindex getbrowserfordocument getbrowserfortab getbrowserindexfordocument getbutton getdefaultsession geteditor ge
telementsbyattribute ge
telementsbyattributens getformattedstring gethtmleditor getindexoffir...
... sizeto startediting stop stopediting swapdocshells syncsessions timedselect toggleitemselection related dom element methods dom:element.addeventlistener dom:element.appendchild dom:element.comparedocumentposition dom:element.dispatchevent dom:element.getattribute dom:element.getattributenode dom:element.getattributenodens dom:element.getattributens dom:element.ge
telementsbytagname dom:element.ge
telementsbytagnamens dom:element.getfeature fixme: brokenlink dom:element.getuserdata dom:element.hasattribute dom:element.hasattributens dom:element.hasattributes dom:element.haschildnodes dom:element.insertbefore dom:element.isequalnode dom:element.issamenode dom:element.issupported dom:element.lookupnamespaceuri dom:element.lookupprefix ...
Extensions - Archive of obsolete content
function init() { var contextmenu = document.ge
telementbyid("contentareacontextmenu"); if (contextmenu) contextmenu.addeventlistener("popupshowing", thumbnailsshowhideitems, false); } function thumbnailsshowhideitems(event) { var show = document.ge
telementbyid("thumbnail-show"); show.hidden = (document.popupnode.localname != "img"); } the init function should be called within the handler for the load event so that the popupshowing ev...
... function thumbnailsshowhideitems(event) { var show = document.ge
telementbyid("thumbnail-show"); show.hidden = !(gcontextmenu.onimage || gcontextmenu.onlink); } ...
Panels - Archive of obsolete content
for instance, using the search panel example above, we could add a button which closes the panel when pressed: <script> function dosearch() { document.ge
telementbyid("search-panel").hidepopup(); } </script> <toolbarbutton label="search" type="panel"> <panel id="search-panel" position="after_start"> <textbox id="search"/> <button label="search" oncommand="dosearch();"/> </panel> </toolbarbutton> in this example, the dosearch() function is called when the "search" button is pressed.
...for instance, to have the textbox initially focused in the example above: <panel id="search-panel" onpopupshown="document.ge
telementbyid('search').focus()"> to disable the adjusting of focus when a panel is opened, set the noautofocus attribute to true: <panel noautofocus="true"> this will cause the focus to remain on the element within the main window that has focus when the panel is opened.
Filtering - Archive of obsolete content
function applyfilter(country) { var cond = document.ge
telementbyid("cond"); var triple = document.ge
telementbyid("filtertriple"); if (country) { if (!triple) { triple = document.createelement("triple"); triple.id = "filtertriple"; triple.setattribute("subject", "?photo"); triple.setattribute("predicate", "http://www.xulplanet.com/rdf/country"); } triple.setattribute("object", country); cond.appendchild(triple)...
...; } else if (triple) { cond.removechild(triple); } document.ge
telementbyid("photoslist").builder.rebuild(); } the 'country' argument to the applyfilter function holds the value to filter by.
RDF Modifications - Archive of obsolete content
actually, internally, this isn't any different than the other notifications, but it is worth discussing separa
tely.
...the template builder then rebuilds the template comple
tely when done.
SQLite Templates - Archive of obsolete content
you would likely want to add an id to the param element so that the ge
telementbyid method may be used to refer to it.
...we could later change the age to use in the query with a short script: function adjustage(min, max) { document.ge
telementbyid("minage").textcontent = min; document.ge
telementbyid("maxage").textcontent = max; document.ge
telementbyid("friends").builder.rebuild(); } this function takes two arguments, the minimum and maximum values to use.
textbox (Toolkit autocomplete) - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
... related interfaces nsiaccessibleprovider, nsiautocompleteinput, nsidomxulmenulis
telement articles how to implement custom autocomplete search component ...
The Joy of XUL - Archive of obsolete content
in practical terms, this enables developers to maintain one code stream for a given application, then apply custom branding or include special features for customers with a comple
tely independent code base.
... fortuna
tely, an implementation of the libical library was already available for macintosh so, with the cross platform nature of xpcom, a macintosh calendar implementation was working within a few days.
Things I've tried to do with XUL - Archive of obsolete content
this means that creating any sort of visual display (not necessarily "ui"; my use case is for creating a calendar time display) that sizes sanely when the user resizes the window is unfortuna
tely very difficult.
...var available_width = document.ge
telementbyid("invisible_element").clientwidth; ...
Creating toolbar buttons (Customize Toolbar Window) - Archive of obsolete content
a simple document.ge
telementbyid('browsertoolbarpalette') will not work.
... the advantage to adding the toolbar button to the palette rather than creating an element and then appendchild to the toolbar (document.ge
telementbyid('nav-bar')) or appendchild to the addon bar (document.ge
telementbyid('addon-bar')) is that once in the toolbar palette, users can configure it through the customize menu.
Adding Labels and Images - Archive of obsolete content
</description> you can set the text via script using the textcontent property, as in the following example: <description id="text" width="200"/> document.ge
telementbyid('text').textcontent = "some lengthy word wrapped text goes here."; internally, both the label element and the description elements are the same.
...this element is appropria
tely named image.
Adding Properties to XBL-defined Elements - Archive of obsolete content
that way, all you need is to get a reference to the element (using document.ge
telementbyid or a similar function) and then get or set the additional properties and call the methods on it.
...xul: <box id="random-box" class="randomizer"/> <button label="generate" oncommand="document.ge
telementbyid('random-box').number=math.random();"/> <button label="show" oncommand="alert(document.ge
telementbyid('random-box').number)"/> xbl: <binding id="randomizer"> <implementation> <field name="number"/> </implementation> </binding> a number field has been defined in the binding, which stores the random number.
Custom Tree Views - Archive of obsolete content
function setview(){ document.ge
telementbyid('my-tree').view = treeview; } the following presents the example together.
...ion(row){ return false; }, isseparator: function(row){ return false; }, issorted: function(){ return false; }, getlevel: function(row){ return 0; }, getimagesrc: function(row,col){ return null; }, getrowproperties: function(row,props){}, getcellproperties: function(row,col,props){}, getcolumnproperties: function(colid,col,props){} }; function setview(){ document.ge
telementbyid('my-tree').view = treeview; } </script> <tree id="my-tree" flex="1"> <treecols> <treecol id="namecol" label="name" flex="1"/> <treecol id="datecol" label="date" flex="1"/> </treecols> <treechildren/> </tree> </window> in the image, you can see two columns, each with data taken from the getcelltext() function.
More Event Handlers - Archive of obsolete content
example 2 : source view <hbox id="outerbox"> <button id="okbutton" label="ok"/> </hbox> <script> function buttonpressed(event){ alert('button was pressed!'); } function boxpressed(event){ alert('box was pressed!'); event.stoppropagation(); } var button = document.ge
telementbyid("okbutton"); button.addeventlistener('command',buttonpressed,true); var outerbox = document.ge
telementbyid("outerbox"); outerbox.addeventlistener('command',boxpressed,true); </script> here, an event listener has been added to the button and another event listener has been added to the box.
...here is an example which displays the current mouse coordinates: example 4 : source view <script> function updatemousecoordinates(e){ var text = "x:" + e.clientx + " y:" + e.clienty; document.ge
telementbyid("xy").value = text; } </script> <label id="xy"/> <hbox width="400" height="400" onmousemove="updatemousecoordinates(event);"/> in this example, the size of the box has been set explicitly so the effect is easier to see.
Property Files - Archive of obsolete content
var strbundle = document.ge
telementbyid("strings"); var nofilesfound=strbundle.getstring("notfoundalert"); alert(nofilesfound); this example first gets a reference to the bundle using its id then, it looks up the string 'notfoundalert' in the property file.
...var dir = "/usr/local/document"; var count = 10; var strbundle = document.ge
telementbyid("strings"); var result = strbundle.getformattedstring("resultmessage", [ dir, count ]); alert(result); this example will display following message in an alert box.
Splitters - Archive of obsolete content
set this to closest to have the element immedia
tely to the left of the splitter resize.
...set this to closest to have the element immedia
tely to the right of the splitter resize.
Trees - Archive of obsolete content
fortuna
tely, xul provides a couple of built-in view implementations which do most of the hard work for you.
...in this example, the second column will be approxima
tely twice as wide as the first column.
XPCOM Interfaces - Archive of obsolete content
an example is shown below: var bmarks = components.classes["@mozilla.org/browser/bookmarks-service;1"].getservice(); bmarks.queryinterface(components.interfaces.nsibookmarksservice); bmarks.addbookmarkimmedia
tely("http://www.mozilla.org","mozilla",0,null); first, the component "@mozilla.org/browser/bookmarks-service;1" is retrieved and its service is placed in the variable bmarks.
...the function addbookmarkimmedia
tely() provided by this interface can be used to add bookmarks.
Using Visual Studio as your XUL IDE - Archive of obsolete content
compared to a simple text-editor, visual studio gives you some special features when writing xul: in
tellisense / autocompletion for elements and attributes validation syntax coloring (okay, more sophisticated editors like notepad++ provide this as well) before you can use all of this, you have to adjust visual studio a little.
...using xml schemas for validation and in
tellisense visual studio needs the xml schema for xul files.
XULBrowserWindow - Archive of obsolete content
method overview boolean hidechromeforlocation(in string alocation); attributes attribute type description incontentwhi
telist string[] an array of url strings for which chrome is automatically hidden.
...by default, chrome is hidden for about:addons and any other pages in the in content whi
telist.
description - Archive of obsolete content
</description> this is a long section of text that will not word wrap <description value="this is a long section of text that will not word wrap"> </description> this is a long section of dynamically controlled text that will word wrap <description id="desc" style="width: 300px"></description> document.ge
telementbyid('desc').textcontent = "this is a long section of dynamic message text that will word wrap"; attributes crop type: one of the values below if the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the crop attribute.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
dialog - Archive of obsolete content
if it is set to true any changes to settings are supposed to be applied immedia
tely.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
editor - Archive of obsolete content
ument, contentwindow, docshell, editingsession, editortype, webbrowserfind, webnavigation methods geteditor, gethtmleditor, makeeditable examples this example shows how to made the editor editable by setting the designmode property of the loaded html document: <script language="javascript"> function initeditor(){ // this function is called to set up the editor var editor = document.ge
telementbyid("myeditor"); editor.contentdocument.designmode = 'on'; } </script> <editor id="myeditor" editortype="html" src="about:blank" flex="1" type="content-primary"/> once editable, the document can have special formatting and other html pieces added to it using the document.execcommand method: var editor = document.ge
telementbyid("myeditor"); // toggle bold for the current selection ...
... inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
iframe - Archive of obsolete content
="http://mozilla.org" /> <menuitem label="slashdot" value="http://slashdot.org"/> <menuitem label="sourceforge" value="http://sf.net" /> <menuitem label="freshmeat" value="http://freshmeat.net"/> </menupopup> </menulist> <iframe id="myframe" flex="1"/> <script> function donav(obj) { var url = obj.selecteditem.value; // note the firstchild is the menupopup element document.ge
telementbyid('myframe').setattribute('src', url); } </script> attributes showcaret type: boolean whether or not to cause a typing caret to be visible in the content area.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
image - Archive of obsolete content
this would be useful if the images are stored remo
tely or you plan on swapping the image frequently.
..., ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
key - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
...for example: // modify some attributes let key = document.ge
telementbyid(key_id); key.setattribute("modifiers", "alt shift"); // apply the changes let keyset = document.ge
telementbyid(keyset_id); keyset.parentnode.appendchild(keyset); ...
listbox - Archive of obsolete content
el="ruby"/> <listitem label="emerald"/> <listitem label="sapphire" selected="true"/> <listitem label="diamond"/> </listbox> <listbox id="thelist" rows="10" width="400"> <listhead> <listheader label="1ct gem" width="240"/> <listheader label="price" width="150"/> </listhead> <listcols> <listcol/> <listcol flex="1"/> </listcols> </listbox> var thelist = document.ge
telementbyid('thelist'); gems = [ {gem: "ruby", price: "$3,500 - $4,600"}, {gem: "emerald", price: "$700 - 4,250"}, {gem: "blue sapphire", price: "$3,400 - $4,500"}, {gem: "diamond", price: "$5,600 - $16,000"} ]; for (var i = 0; i < gems.length; i++) { var row = document.createelement('listitem'); var cell = document.createelement('listcell'); cell.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
menuitem - Archive of obsolete content
this would be useful if the images are stored remo
tely or you plan on swapping the image frequently.
..., ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
menulist - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
... related elements menu, menubar, menuitem, menupopup, menuseparator interfaces nsiaccessibleprovider, nsidomxulmenulis
telement ...
menupopup - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
...de(), removeattributens(), removechild(), removeeventlistener(), replacechild(), setattribute(), setattributenode(), setattributenodens(), setattributens(), setuserdata hidepopup() return type: no return value closes the popup immedia
tely.
notificationbox - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
...if immediate is true, the messages are removed immedia
tely.
panel - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
...de(), removeattributens(), removechild(), removeeventlistener(), replacechild(), setattribute(), setattributenode(), setattributenodens(), setattributens(), setuserdata hidepopup() return type: no return value closes the popup immedia
tely.
prefpane - Archive of obsolete content
methods domelement getpreferenceelement(in domelement star
telement) preferenceforelement( uielement ) return type: preference element returns the preference element to which a user interface element is attached.
... inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
progressmeter - Archive of obsolete content
ties accessibletype, max, mode, value examples <progressmeter mode="determined" value="82"/> <progressmeter mode="undetermined"/> <!-- switching modes while the mouse is over a button --> <progressmeter mode="determined" id="myprogress"/> <button label="example" onmouseover="setloading(true)" onmouseout="setloading(false)"/> function setloading(state){ document.ge
telementbyid('myprogress').mode = (state) ?
..., ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbarbutton - Archive of obsolete content
this would be useful if the images are stored remo
tely or you plan on swapping the image frequently.
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
tooltip - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
...de(), removeattributens(), removechild(), removeeventlistener(), replacechild(), setattribute(), setattributenode(), setattributenodens(), setattributens(), setuserdata hidepopup() return type: no return value closes the popup immedia
tely.
window - Archive of obsolete content
you can use this as a parameter to ge
telementbyid() and other dom functions and to reference the element in style sheets.
..., ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
wizard - Archive of obsolete content
nt, pageindex, pagestep, title, wizardpages methods advance, cancel, extra1, extra2, getbutton, getpagebyid, goto, rewind examples <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <wizard id="thewizard" title="secret code wizard" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script> function checkcode(){ document.ge
telementbyid('thewizard').canadvance = (document.ge
telementbyid('secretcode').value == "cabbage"); } </script> <wizardpage onpageshow="checkcode();"> <label value="enter the secret code:"/> <textbox id="secretcode" onkeyup="checkcode();"/> </wizardpage> <wizardpage> <label value="that is the correct secret code."/> </wizardpage> </wizard> attributes activetitlebarco...
... methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
Debugging a XULRunner Application - Archive of obsolete content
the easiest way to debug a xulrunner application is to get the system to
tell you what's wrong!
...tors("myxulrunnerappwindowtype"); } debuggerserver.openlistener(6000); for xulrunner version 37+ the code to enable the debugger has changed: components.utils.import('resource://gre/modules/devtools/dbg-server.jsm'); if (!debuggerserver.initialized) { debuggerserver.init(); debuggerserver.addbrowseractors(); debuggerserver.allowchromeprocess = true; } let dbglistener=debuggerserver.crea
telistener(); dbglistener.portorpath=6000; dbglistener.open(); add the following to your prefs.js: (in recent ffox, edit about:config instead) pref("devtools.debugger.remote-enabled", true); in firefox, go to tools > web developer > connect...
Mozilla release FAQ - Archive of obsolete content
this list will be updated with time, but (according to netscape.public.mozilla.general) the following platforms have been built successfully: solaris 2.4, 2.5, 2.6 freebsd 2.2, 3.0 linux/in
tel and alpha 2.0, 2.1 macos winnt 4.0 irix 5.3, 6.2, 6.3, 6.4 win95, win98 digital unix 4.0 netbsd openbsd bsdi hp/ux 9.05, 10.20, 11.0 (see 2.7) hurd .03 dg/ux mac os x i'm *still* having problems getting mozilla to build on my platform!
...also, progressive display of the webpage would be comple
tely gone with this idea.
2006-10-27 - Archive of obsolete content
on the same day cédric replied to axel's posting stating that he was going to forward a note to tristan separa
tely.
... on the same day paul reed replied to cédric's posting by stating that they would like to close the directory before major releases but that unfortuna
tely it wasn't that easy to do because the files must be readable, so mirrors can get the bits to serve them on the release day.
NPN_GetURLNotify - Archive of obsolete content
it returns immedia
tely and only later handles the request and calls npp_urlnotify().
... this notification is the only way the plug-in can
tell whether a request with a null target failed, or that a request with a non-null target completed.
XEmbed Extension for Mozilla Plugins - Archive of obsolete content
telling mozilla you support xembed as mentioned above, you will need to
tell mozilla that you support the xembed protocol for hosting plugins.
... for backwards compatibility reasons if you don't
tell mozilla that you support it it will try to hand you an xt widget as a parent.
SAX - Archive of obsolete content
an example implementation of the most commonly used content handler: function print(s) { dump(s + "\n"); } xmlreader.contenthandler = { // nsisaxcontenthandler startdocument: function() { print("startdocument"); }, enddocument: function() { print("enddocument"); }, star
telement: function(uri, localname, qname, /*nsisaxattributes*/ attributes) { var attrs = []; for(var i=0; i<attributes.length; i++) { attrs.push(attributes.getqname(i) + "='" + attributes.getvalue(i) + "'"); } print("star
telement: namespace='" + uri + "', localname='" + localname + "', qname='" + qname + "', attributes={" + attrs.join(",") +...
...below is an example of parsing from a string: xmlreader.parsefromstring("<f:a xmlns:f='g' d='1'><bbq/></f:a>", "text/xml"); this call results in the following output (assuming the content handler from the example above is used): startdocument star
telement: namespace='g', localname='a', qname='f:a', attributes={d='1'} star
telement: namespace='', localname='bbq', qname='bbq', attributes={} endelement: namespace='', localname='bbq', qname='bbq' endelement: namespace='g', localname='a', qname='f:a' enddocument ...
Security - Archive of obsolete content
but encryption and decryption, by themselves, do not address another problem: tampering.encryption and decryptionencryption is the process of transforming information so it is unin
telligible to anyone but the intended recipient.
... decryption is the process of transforming encrypted information so that it is in
telligible again.introduction to public-key cryptographypublic-key cryptography and related standards and techniques underlie the security features of many products such as signed and encrypted email, single sign-on, and secure sockets layer (ssl) communications.
Solaris 10 Build Prerequisites - Archive of obsolete content
fortuna
tely, it also isn't necessary, so you can fix this problem by simply removing the reference to that package from the installer script (cbe-install).
... the installer may
tell you your c compiler is not the recommended compiler, but the compiler you installed will work fine, so you should
tell the installer to use the compiler anyway.
Table Reflow Internals - Archive of obsolete content
absolu
tely positioned elements) reflows reflowee and passes a reflow state (in) and a reflow metrics (in/out) review of reflow the reflow state: is a node in a tree structurally equivalent to the frame tree of reflow participants contains: reflow type, avail size, various computed values, resolved style structs possible request for preferred size and more.
...when a target is the cell or below and the cell changes size, the row
tells the table so it can decide if it needs to rebalance when a target is inside the cell's block, the cell requests max element, preferred sizes of its block in case they change after the table reflows the row group(s) containing the targets, if it rebalances, it then does a pass 2 reflow.
Common Firefox theme issues and solutions - Archive of obsolete content
this document was started on july 27, 2012 so it will take some time to comple
tely fill in and some issues still need to have solutions written for them.
... */ #inspector-treepanel-toolbutton { list-style-image: url("chrome://browser/skin/devtools/treepanel-button.png"); -moz-margin-end: 0; -moz-image-region: rect(0px 18px 16px 0px); } /* highlighter toolbar */ #inspector-inspect-toolbutton { list-style-image: url("chrome://browser/skin/devtools/inspect-button.png"); -moz-image-region: rect(0px 16px 16px 0px); } style inspector is comple
tely unstyled the style inspector that is part of firefox 10 and later needs to be styled.
CSS - Archive of obsolete content
normally, a <xul:stack> will change its size so that all of its child elements are comple
tely visible.
...this is important in that it provides a natural way to
tell several voices apart, as each can be positioned to originate at a different location on the sound stage.
Debug.write - Archive of obsolete content
the debug.write function is almost identical to the debug.wri
teln function.
... the only difference is that the debug.wri
teln function sends a newline character after the strings are sent.
Debug - Archive of obsolete content
in windows 8.x store apps, the write and wri
teln functions of the debug object display strings in the visual studio output window at run time.
... debug.wri
teln sends strings to the script debugger, followed by a newline character.
Archived JavaScript Reference - Archive of obsolete content
you can use the more general proxy object instead.arraybuffer.transfer()the static arraybuffer.transfer() method returns a new arraybuffer whose contents have been taken from the oldbuffer's data and then is either truncated or zero-extended by newby
telength.
... if newby
telength is undefined, the by
telength of the oldbuffer is used.
Sharp variables in JavaScript - Archive of obsolete content
form sharp variables have the form of a sharp sign (#) immedia
tely followed by one or more digits.
... #1 = {}; // this doesn't do much since the sharp variable is out of scope immedia
tely after a = #2 = {}; // slightly more useful since we retain a reference to the new object to reference the sharp variable, simply append another sharp (#) to the end of the variable name.
Choosing Standards Compliance Over Proprietary Practices - Archive of obsolete content
for example, if an organization is developing a web-based client, they may have to adhere to standards imposed by these organizations: ansi (american national standards institute ) atsc (advanced
television systems committee ) ieee (institute of electrical and electronics engineers ) ietf (internet engineering task force ) irtf (internet research task force ) iso (international standards organization ) itu (international
telecommunication union ) oasis (organization for the advancement of structured information standards ) oma (open mobile alliance ), uni (unicode consortium ) w3c (w...
...however, when mac os x was released, apple comple
tely revamped the interface and desktop metaphor.
Displaying a graphic with audio samples - Archive of obsolete content
html> <html> <head> <title>javascript spectrum example</title> </head> <body> <audio id="audio-element" src="revolve.ogg" controls="true" style="width: 512px;"> </audio> <div><canvas id="fft" width="512" height="200"></canvas></div> <img id="mozlogo" style="display:none" src="mozilla2.png"></img> <script> var canvas = document.ge
telementbyid('fft'), ctx = canvas.getcontext('2d'), channels, rate, framebufferlength, fft; function loadedmetadata() { channels = audio.mozchannels; rate = audio.mozsamplerate; framebufferlength = audio.mozframebufferlength; fft = new fft(framebufferlength / channels, rate); ...
....fillrect (0,0, canvas.width, canvas.height); ctx.fillstyle = "rgb(255,255,255)"; for (var i = 0; i < signal.length; i++ ) { // multiply spectrum by a zoom value magnitude = signal[i] * 1000; // draw rectangle bars for each frequency bin ctx.fillrect(i * 4, canvas.height, 3, -magnitude); } ctx.drawimage(document.ge
telementbyid('mozlogo'),0,0, canvas.width, canvas.height); } var audio = document.ge
telementbyid('audio-element'); audio.addeventlistener('mozaudioavailable', audioavailable, false); audio.addeventlistener('loadedmetadata', loadedmetadata, false); </script> </body> </html> ...
Fixing Incorrectly Sized List Item Markers - Archive of obsolete content
the solution fortuna
tely, there are mozilla-specific css-like rules that can be used to correct both problems.
... the following rule is derived from mozilla's html.css file: *|*:-moz-list-bullet, *|*:-moz-list-number {font-size: 1em;} this rule
tells gecko-based browsers to use the computed value of font-size for the marker's parent, which is the list item itself.
The Business Benefits of Web Standards - Archive of obsolete content
while some browsers have quirks that cause different behavior by platform, mozilla-based browsers are designed to behave identically on all supported platforms (mac, linux, unix, windows...) web content is increasingly being accessed by a growing number of user agents other than browsers, or by browsers on different platforms - for example mobile
telephones.
...ultima
tely that better user experience delivers the business or operational objectives of the site.
Windows Media in Netscape - Archive of obsolete content
fortuna
tely, windows media player also fires a scriptcommand() event for closed captioning, which means content may update the caption manually with a small piece of javascript.
...instead of doing that, this is the recommendation and workaround for netscape 7.1: <script for="player" event="scriptcommand(type, param)"> if (type == "text") { var cap = document.ge
telementbyid("captext"); cap.innerhtml = param; } </script> more detailed examples are available in the final section on examples and sample code.
Common causes of memory leaks in extensions - Extensions
all zombie compartments in extensions are caused by a failure to release resources appropria
tely in certain circumstances, such as when a window is closed, a page unloads, or an extension is disabled or removed.
... consider the following example: var myobserver = { observe: function(subject, topic, data) { window.document.documen
telement.setattribute( "pbm", (data == "enter") ?
Index - Game development
fortuna
tely, i do not have any experience with this, but i have heard it is an excruciating game of whack-a-mole.
... 68 paddle and keyboard controls beginner, canvas, controls, games, graphics, javascript, tutorial, keyboard the ball is bouncing off the walls freely and you can watch it indefini
tely, but currently there's no interactivity.
Bounding volume collision detection with THREE.js - Game development
var knot = new three.mesh( new three.torusknotgeometry(0.5, 0.1), new meshnormalmaterial({})); var knotbsphere = new sphere( knot.position, knot.geometry.boundingsphere.radius); unfortuna
tely, there is no equivalent of box3.setfromobject for sphere instances.
...box3 unfortuna
tely this test is not implemented in three.js, but we can patch sphere to implement a sphere vs.
Building up a basic demo with Babylon.js - Game development
ml structure here's the html structure we will use: <!doctype html> <html> <head> <meta charset="utf-8"> <title>mdn games: babylon.js demo</title> <style> html,body,canvas { margin: 0; padding: 0; width: 100%; height: 100%; font-size: 0; } </style> </head> <body> <script src="babylon.js"></script> <canvas id="render-canvas"></canvas> <script> var canvas = document.ge
telementbyid("render-canvas"); /* all our javascript code goes here */ </script> </body> </html> it contains some basic information like the document <title>, and some css to set the width and height of the <canvas> element (which babylon.js will use to render the content on) to fill the entire available viewport space.
... var renderloop = function () { scene.render(); }; engine.runrenderloop(renderloop); we're using the engine's runrenderloop() method to execute the renderloop() function repeatedly on every frame — the loop will continue to render indefini
tely until told to stop.
Building up a basic demo with the PlayCanvas engine - Game development
<!doctype html> <html> <head> <meta charset="utf-8"> <title>mdn games: playcanvas demo</title> <style> body { margin: 0; padding: 0; } canvas { width: 100%; height: 100%; } </style> </head> <body> <script src="playcanvas-latest.js"></script> <canvas id="application-canvas"></canvas> <script> var canvas = document.ge
telementbyid("application-canvas"); /* all our javascript code goes here */ </script> </body> </html> it contains some basic information like the document <title>, and some css to set the width and height of the <canvas> element that playcanvas will use to 100% so that it will fill the entire available viewport space.
... the cube is visible, but it is comple
tely.
GLSL Shaders - Game development
applying the shaders to actually apply the newly created shaders to the cube, comment out the basicmaterial definition first: // var basicmaterial = new three.meshbasicmaterial({color: 0x0095dd}); then, create the shadermaterial: var shadermaterial = new three.shadermaterial( { vertexshader: document.ge
telementbyid( 'vertexshader' ).textcontent, fragmentshader: document.ge
telementbyid( 'fragmentshader' ).textcontent }); this shader material takes the code from the scripts and applies it to the object the material is assigned to.
... height); renderer.setclearcolor(0xdddddd, 1); document.body.appendchild(renderer.domelement); var scene = new three.scene(); var camera = new three.perspectivecamera(70, width/height); camera.position.z = 50; scene.add(camera); var boxgeometry = new three.boxgeometry(10, 10, 10); var shadermaterial = new three.shadermaterial( { vertexshader: document.ge
telementbyid( 'vertexshader' ).textcontent, fragmentshader: document.ge
telementbyid( 'fragmentshader' ).textcontent }); var cube = new three.mesh(boxgeometry, shadermaterial); scene.add(cube); cube.rotation.set(0.4, 0.2, 0); function render() { requestanimationframe(render); renderer.render(scene, camera); } render(); css body { margin: 0; paddi...
Unconventional controls - Game development
this approach won't give us the full flexibility of using a gamepad, or even leap motion, but it's defini
tely an interesting, unconventional alternative.
... makey makey if you want to go comple
tely bananas you can use makey makey, a board that can turn anything into a controller — it's all about connecting real-world, conductive objects to a computer and using them as touch interfaces.
Asynchronous - MDN Web Docs Glossary: Definitions of Web-related terms
networking and communications asynchronous communication is a method of exchanging messages between two or more parties in which each party receives and processes messages whenever it's convenient or possible to do so, rather than doing so immedia
tely upon receipt.
...for example, the ajax (asynchronous javascript and xml) programming technique—now usually simply "ajax", even though json is usually used rather than xml in modern applications—is a mechanism that requests relatively small amounts of data from the server using http, with the result being returned when available rather than immedia
tely.
Function - MDN Web Docs Glossary: Definitions of Web-related terms
function loop(x) { if (x >= 10) return; loop(x + 1); }; //using ecmascript 2015 arrow notation const loop = x => { if (x >= 10) return; loop(x + 1); }; an immedia
tely invoked function expressions (iife) is a function that is called directly after the function is loaded into the browser’s compiler.
... // declared functions can't be called immedia
tely this way // error (https://en.wikipedia.org/wiki/immedia
tely-invoked_function_expression) /* function foo() { console.log('hello foo'); }(); */ // function expressions, named or anonymous, can be called immedia
tely (function foo() { console.log("hello foo"); }()); (function food() { console.log("hello food"); })(); (() => console.log('hello world'))(); if you'd like to know more about iifes, check out the following page on wikipedia : immedia
tely invoked function expression learn more technical reference functions arrow functions ...
ITU - MDN Web Docs Glossary: Definitions of Web-related terms
the international
telecommunication union (itu) is the organization authorized by the united nations to establish standards and rules for
telecommunication, including
telegraph, radio,
telephony and the internet.
... in the internet age, the itu's role of establishing standards for video and audio data formats used for streaming,
teleconferencing, and other purposes.
Request header - MDN Web Docs Glossary: Definitions of Web-related terms
a few request headers after a get request: get /home.html http/1.1 host: developer.mozilla.org user-agent: mozilla/5.0 (macintosh; in
tel mac os x 10.9; rv:50.0) gecko/20100101 firefox/50.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate, br referer: https://developer.mozilla.org/testpage.html connection: keep-alive upgrade-insecure-requests: 1 if-modified-since: mon, 18 jul 2016 02:36:04 gmt if-none-match: "c561c68d0ba92bbeb8b0fff2a9199f722e3a62...
...1a" cache-control: max-age=0 strictly speaking, the content-length header in this example is not a request header like the others, but an entity header: post /myform.html http/1.1 host: developer.mozilla.org user-agent: mozilla/5.0 (macintosh; in
tel mac os x 10.9; rv:50.0) gecko/20100101 firefox/50.0 content-length: 128 learn more technical knowledge list of all http headers ...
VoIP - MDN Web Docs Glossary: Definitions of Web-related terms
it is also known as ip
telephony, or broadband
telephony.
...usually,
telephone calls over the internet do not incur further charges beyond what the user is paying for internet access, much in the same way that the user doesn't pay for sending individual emails over the internet.
Application Context - MDN Web Docs Glossary: Definitions of Web-related terms
if an application context is created as a result of the user agent being asked to navigate to a deep link, the user agent must immedia
tely navigate to the deep link with replacement enabled.
... otherwise, when the application context is created, the user agent must immedia
tely navigate to the start url with replacement enabled.
MDN Web Docs Glossary: Definitions of Web-related terms
server timing session hijacking sgml shadow tree shim signature signature (functions) signature (security) simd simple header simple response header sisd site site map sld sloppy mode slug smoke test smpte (society of motion picture and
television engineers) smtp snap positions soap spa (single-page application) specification speculative parsing speed index sql sql injection sri stacking context state machine statement static method static typing strict mode string stun ...
... style origin stylesheet svg svn symbol symmetric-key cryptography synchronous syntax syntax error synthetic monitoring t tag tcp tcp handshake tcp slow start
telnet texel thread three js time to first byte time to interactive tld tofu transmission control protocol (tcp) transport layer security (tls) tree shaking trident truthy ttl turn type type coercion type conversion u udp (user datagram protocol) ui undefined unicode uri ur...
Test your skills: CSS and JavaScript accessibility - Learn web development
however, their accessibility is pretty bad — there is no way to really
tell that they are links, or to
tell which one the user is focussed on.
... we'd like you to assume that the existing ruleset with the a selector is supplied by some cms, and that you can't change it — instead, you need to create new rules to make the links look and behave like links, and for the user to be able to
tell where they are in the list.
Accessible multimedia - Learn web development
for example, some users may not be able to hear the audio because they are in noisy environments (like a crowded bar when a sports game is being shown) or might not want to disturb others if they are in a quiet place (like a library.) this is not a new concept —
television services have had closed captioning available for quite a long time: whereas many countries offer english films with subtitles written in their own native languages, and different language subtitles are often available on dvds, for example there are different types of text track with different purposes.
...furthermore, use srclang to
tell the browser what language you have written the subtitles in.
Backgrounds and borders - Learn web development
you can also use keywords: cover — the browser will make the image just large enough so that it comple
tely covers the box area while still retaining its aspect ratio.
... the value of background-size may only be included immedia
tely after background-position, separated with the '/' character, like this: center/80%.
Attribute selectors - Learn web development
[attr|=value] div[lang|="zh"] matches elements with an attr attribute whose value is exactly value or begins with value immedia
tely followed by a hyphen.
...this flag
tells the browser to match ascii characters case-insensitively.
Sizing items in CSS - Learn web development
this technique is used to make images responsive, so that when viewed on a smaller device they scale down appropria
tely.
...images should be appropria
tely sized to be no larger than they need to be for the largest size they are displayed in the design.
Styling tables - Learn web development
unfortuna
tely, it doesn't look good when rendered on the screen (see it live at punk-bands-unstyled.html): with only the default browser styling it looks cramped, hard to read, and boring.
...yes, we could have put both the background image and the linear gradient on the <thead> and <tfoot> elements using multiple background images, but we decided to do it separa
tely for the benefit of older browsers that don't support multiple background images or linear gradients.
The box model - Learn web development
by doing this you are
telling the browser to take the border box as the area defined by any size you set.
...try changing this to display: block or removing the line comple
tely to see the difference in display models.
Beginner's guide to media queries - Learn web development
media query basics the simplest media query syntax looks like this: @media media-type and (media-feature-rule) { /* css rules go here */ } it consists of: a media type, which
tells the browser what kind of media this code is for (e.g.
... to remedy this, including a viewport meta tag like the one above on your page
tells the browser "don't render the content with a 960 pixel viewport — render it using the real device width instead, and set a default initial scale level for better consistency." the media queries will then kick in as expected.
Supporting older browsers - Learn web development
this is straightforward if you have an existing website which you are adding to or replacing, as you probably have analytics available which can
tell you the technology people are using.
...browsers that do not support grid, and do not support the feature query will use that layout information they can understand and comple
tely ignore everything else.
Getting started with CSS - Learn web development
adding css to our document the very first thing we need to do is to
tell the html document that we have some css rules we want it to use.
... to link styles.css to index.html add the following line somewhere inside the <head> of the html document: <link rel="stylesheet" href="styles.css"> this <link> element
tells the browser that we have a stylesheet, using the rel attribute, and the location of that stylesheet as the value of the href attribute.
How CSS is structured - Learn web development
each css rule starts with a selector—or a list of selectors—in order to
tell the browser which element or elements the rules should apply to.
...it is comple
tely ignored by the browser's css engine.
CSS FAQ - Learn web development
it is generally recommended to use classes as much as possible, and to use ids only when absolu
tely necessary for specific uses (like to connect label and form elements or for styling elements that must be semantically unique): using classes makes your styling extensible — even if you only have one element to style with a particular ruleset now, you might want to add more later.
...for example, many developers only using the -webkit- prefixed version of a property when the non-prefixed version is supported across all browsers meant that a feature relying on that property would break in non-webkit-based browsers, comple
tely needlessly.
Learn to style HTML using CSS - Learn web development
however, doing so isn't absolu
tely necessary as much of what is covered in the css basics article is also covered in our css first steps module, albeit in a lot more detail.
...you should defini
tely start with the first one.
What do common web layouts contain? - Learn web development
in fact, everything not absolu
tely required by the page's main content.
...the way the curve of the header's menu ties in with the curve at the bottom of the image, the header and main content look like one thing even though they're technically comple
tely different.
How can we design for all types of users? - Learn web development
for instance, if in your css you declare this: body { font-size:16px; } … you are
telling the browser that whatever happens, the font size must be 16 pixels.
... relative units are expressed in em, % and rem: percent-based sizes: % this unit
tells your browser that an element's font size must be n% of the previous element whose font size was expressed.
How do I use GitHub Pages? - Learn web development
here's what you'd type if you've put your website in a directory called test-site on your desktop: cd desktop/test-site when the command line is pointing inside your website directory, type the following command, which
tells the git tool to turn the directory into a git repository: git init an aside on command line interfaces the best way to upload your code to github is via the command line — this is a window where you type in commands to do things like create files and run programs, rather than clicking inside a user interface.
...you
tell the computer to do something in the terminal by typing in a command and hitting enter, as seen above.
What is a URL? - Learn web development
deeper dive basics: anatomy of a url here are some examples of urls: https://developer.mozilla.org https://developer.mozilla.org/docs/learn/ https://developer.mozilla.org/search?q=url any of those urls can be typed into your browser's address bar to
tell it to load the associated page (resource).
...so in this example, we really want to reach this url: https://developer.mozilla.org/docs/learn/skills/infrastructure/understanding_urls going back in the directory tree ../css/display in this case, we use the ../ writing convention — inherited from the unix file system world — to
tell the browser we want to go up from one directory.
Basic native form controls - Learn web development
other text input types, like search, url, and
tel, were added with html5.
...the associated <label> is generally placed immedia
tely after the radio button or checkbox, with the instructions for the group of radio button or checkboxes generally being the content of the <legend>.
Sending form data - Learn web development
this header is very important because it
tells the server what kind of data is being sent.
...store them on a different server and allow access to the file only through a different subdomain or even better through a comple
tely different domain.
Dealing with files - Learn web development
an aside on casing and spacing you'll notice that throughout this article, we ask you to name folders and files comple
tely in lowercase with no spaces.
...we need to
tell the html where the image is.
JavaScript basics - Learn web development
for example, the alert() function makes a pop-up box appear inside the browser window, but we need to give it a string as an argument to
tell the function what message to display.
...for example: multiply(4, 7); multiply(20, 20); multiply(0.5, 3); note: the return statement
tells the browser to return the result variable out of the function so it is available to use.
Marking up a letter - Learn web development
inline semantics the names of the sender and receiver (and
tel and email) should be marked up with strong importance.
... the six sub/superscripts should be marked up appropria
tely — in the chemical formulae, and the numbers 103 and 104 (they should be 10 to the power of 3 and 4, respectively).
Adding vector graphics to the Web - Learn web development
here's a quick review: <iframe src="triangle.svg" width="500" height="500" sandbox> <img src="triangle.png" alt="triangle with three unequal sides" /> </iframe> this is defini
tely not the best method to choose: cons iframes do have a fallback mechanism, as you can see, but browsers only display the fallback if they lack support for iframes altogether.
...g> </textarea> <div class="playable-buttons"> <input id="reset" type="button" value="reset"> <input id="solution" type="button" value="show solution" disabled> </div> html { font-family: sans-serif; } h2 { font-size: 16px; } .a11y-label { margin: 0; text-align: right; font-size: 0.7rem; width: 98%; } body { margin: 10px; background: #f5f9fa; } const textarea = document.ge
telementbyid('code'); const reset = document.ge
telementbyid('reset'); const solution = document.ge
telementbyid('solution'); const output = document.queryselector('.output'); let code = textarea.value; let userentry = textarea.value; function updatecode() { output.innerhtml = textarea.value; } reset.addeventlistener('click', function() { textarea.value = code; userentry = textarea.value; sol...
Structuring the web with HTML - Learn web development
it is recommended that you work through getting started with the web before attempting this topic, however, it isn't absolu
tely necessary; much of what is covered in the html basics article is also covered in our introduction to html module, albeit in a lot more detail.
...you should defini
tely start with the first one.
Choosing the right approach - Learn web development
we then run it once per second using setinterval(), creating the effect of a digital clock that updates once per second (see this live, and also see the source): function displaytime() { let date = new date(); let time = date.tolocaletimestring(); document.ge
telementbyid('demo').textcontent = time; } const createclock = setinterval(displaytime, 1000); pitfalls the frame rate isn't optimized for the system the animation is running on, and can be somewhat inefficient.
... further information cooperative asynchronous javascript: timeouts and intervals, in particular requestanimationframe() requestanimationframe() reference promises promises are a javascript feature that allows you to run asynchronous operations and wait until it is defini
tely complete before running another operation based on its result.
Introduction to events - Learn web development
previous overview: building blocks next events are actions or occurrences that happen in the system you are programming, which the system
tells you about so you can respond to them in some way if desired.
...if they are, we call the preventdefault() function on the event object — which stops the form submission — and then display an error message in the paragraph below our form to
tell the user what's wrong: const form = document.queryselector('form'); const fname = document.ge
telementbyid('fname'); const lname = document.ge
telementbyid('lname'); const para = document.queryselector('p'); form.onsubmit = function(e) { if (fname.value === '' || lname.value === '') { e.preventdefault(); para.textcontent = 'you need to fill in both names!'; } } obviously, this is pr...
Introduction to web APIs - Learn web development
examples include
telling the user that a useful update is available on a web app via system notifications (see the notifications api) or vibration hardware (see the vibration api).
... the
telegram apis allows you to embed content from
telegram channels on your website, in addition to providing support for bots.
Third-party APIs - Learn web development
they are found on third-party servers browser apis are built into the browser — you can access them from javascript immedia
tely.
...try this, for example: map.addcontrol(l.mapquest.control({ position: 'bottomright' })); there are other types of control available, for example mapquest.searchcontrol() and mapquest.sa
tellitecontrol(), and some are quite complex and powerful.
Inheritance in JavaScript - Learn web development
to create a subclass we use the extends keyword to
tell javascript the class we want to base our class on, class teacher extends person { constructor(subject, grade) { this.subject = subject; this.grade = grade; } } but there's a little catch.
... ultima
tely, objects are just another form of code reuse, like functions or loops, with their own specific roles and advantages.
Working with JSON - Learn web development
"name": "madame uppercut", "age": 39, "secretidentity": "jane wilson", "powers": [ "million tonne punch", "damage resistance", "superhuman reflexes" ] }, { "name": "eternal flame", "age": 1000000, "secretidentity": "unknown", "powers": [ "immortality", "heat immunity", "inferno", "
teleportation", "interdimensional travel" ] } ] } if we loaded this object into a javascript program, parsed in a variable called superheroes for example, we could then access the data inside it using the same dot/bracket notation we looked at in the javascript object basics article.
... we have wrapped the code in an event handler that runs when the load event fires on the request object (see onload) — this is because the load event fires when the response has successfully returned; doing it this way guarantees that request.response will defini
tely be available when we come to try to do something with it.
Object building practice - Learn web development
drawing the ball first add the following draw() method to the ball()'s prototype: ball.prototype.draw = function() { ctx.beginpath(); ctx.fillstyle = this.color; ctx.arc(this.x, this.y, this.size, 0, 2 * math.pi); ctx.fill(); } using this function, we can
tell the ball to draw itself onto the screen, by calling a series of members of the 2d canvas context we defined earlier (ctx).
... immedia
tely inside the for loop, we use an if statement to check whether the current ball being looped through is the same ball as the one we are currently checking.
What is web performance? - Learn web development
the download of additional assets linked to from the index file is generally sequential, based on source order, but this can be manipulated and should defini
tely be optimized, realizing that some resources block additional downloads until their content is parsed and executed.
...next up we'll look at perceived performance, and how you can use some clever techniques to make some unavoidable performance hits appear less severe to the user, or disguise them comple
tely.
Getting started with Ember - Learn web development
developers are then more easily able to switch between projects and applications without having to comple
tely relearn the architecture, patterns, conventions, etc.
... finally, find app.css, located at app/styles/app.css, and paste in the following: :focus, .view label:focus, .todo-list li .toggle:focus + label, .toggle-all:focus + label { /* !important needed because todomvc styles delibera
tely disable the outline */ outline: #d86f95 solid !important; } this css overrides some of the styles provided by the todomvc-app-css npm package, therefore allowing keyboard focus to be visible.
Componentizing our React app - Learn web development
the final line of src/index.js should read like this: reactdom.render(<app tasks={data} />, document.ge
telementbyid("root")); this array is now available to the app component as props.tasks.
... note: all_caps constant names have no special meaning in javascript; they’re a convention that
tells other developers "this data will never change after being defined here”.
Working with Svelte stores - Learn web development
with $: onmessagechange($alert, ms) we
tell svelte to run this function whenever the $alert store or the ms prop changes.
...app.svelte is comple
tely transparent in terms of what kind of store we are using.
Rendering a list of Vue components - Learn web development
to make sure it is re-using list elements appropria
tely, it needs a unique "key" on the same element that you attach v-for to.
... to make sure that vue can accura
tely compare the key attributes, they need to be string or numeric values.
Implementing feature detection - Learn web development
give it the following contents: const conditional = document.queryselector('.conditional'); const tes
telem = document.createelement('div'); if (tes
telem.style.flex !== undefined && tes
telem.style.flexflow !== undefined) { conditional.setattribute('href', 'flex-layout.css'); } else { conditional.setattribute('href', 'float-layout.css'); } here we are grabbing a reference to the second <link> element, and creating a <div> element as part of our test.
...cript inside the tags: if (modernizr.geolocation) { navigator.geolocation.getcurrentposition(function(position) { let latlng = new google.maps.latlng(position.coords.latitude,position.coords.longitude); let myoptions = { zoom: 8, center: latlng, maptypeid: google.maps.maptypeid.terrain, disabledefaultui: true } let map = new google.maps.map(document.ge
telementbyid("map_canvas"), myoptions); }); } else { const para = document.createelement('p'); para.textcontent = 'argh, no geolocation!'; document.body.appendchild(para); } try your example out!
Client-side tooling overview - Learn web development
linters linters are tools that check through your code and
tell you about any errors that are present, what error types they are, and what code lines they are present on.
... there's defini
tely no silver bullet that will guarantee success with tools, but as your experience increases you'll find workflows that work for you or for your team and their projects.
Package management basics - Learn web development
sure there's some calculation, but we defini
tely don’t need 195k worth of javascript to do this!.
... dist/my-project.86f8a5fc.js 10.34 kb 7.17s dist/index.html 288 b 753ms now the bundle is approxima
tely 10k.
Accessibility API cross-reference
n/a accessible_active_descendant_property aria-activedescendant critical info to convey immedia
tely alert_high n/a n/a aria-live=assertive info that's important, but does not require immediacy alert_medium n/a n/a aria-live=polite low-priority info such as a tip or hint alert_low n/a n/a n/a this object is changing or moving rapidly animated n/a n/a n/a ...
...e care of text-to-speech on its own selfvoicing n/a n/a object can be resized n/a resizable resizable this object and all of its ancestors are visible n/a showing showing this text object can only contain 1 line of text n/a single_line single_line
tells accessibility aid "don't add event listener - this object doesn't generate any".
Accessible Toolkit Checklist
since the individual widgets predomina
tely come from the operating system, they already implement standard keyboard commands and follow the operating system's visual theme.
...this is one reason why a label must be created together with each widget, rather than separa
tely.
A bird's-eye view of the Mozilla framework
the client is comple
tely unaware of which c++ class (or other language) actually implements nsirdfnode; it only interacts with the idl interface.
... var toctree = document.ge
telementbyid("help-toc-panel"); the document object is a xuldocument, and toctree is thecontents panel xulelement.
Testopia
despite bugzilla 5.0 has already been released a few months ago, we don't plan to release a fix for testopia immedia
tely, because it's currently under heavy work to make testopia a fully self-contained extension, which means that all tr_*.cgi scripts which are currently in the bugzilla/ root directory are being moved into extensions/testopia/lib/.
...also, future versions may remove this support comple
tely.
What to do and what not to do in Bugzilla
when marking it wfm you should
tell the bug reporter that they should reopen the bug if they can still see it with a recent build.
... note: because of how duplicate detection works in bugzilla, you should try not to verify bugs immedia
tely after they're marked fixed; instead, let a little time pass first.
HTTP logging
if you've put it elsewhere, change the path used on the third line appropria
tely.) reproduce whatever problem you're trying to debug.
... this will cause each log message to be immedia
tely written (and fflush()'d), which is likely to give us more information about your crash.
Configuring Build Options
parallel compilation note: the build system automatically makes an in
telligent guess for how many cpu cores to use when building.
...you will see (diminishing) returns up to a value approxima
tely 1.5× to 2.0× the number of cores on your system.
Reviewer Checklist
[fennec: if your custom view does animations, it's better to clean up runnables in ondetachfromwindow().] ensure all file handles and other closeable resources are closed appropria
tely.
... adequa
tely document any potentially confusing pieces of code.
Multiple Firefox profiles
it takes little time to set up a new profile, and once it is complete, all of your firefox versions will update separa
tely and can be run simultaneously.
... this will launch firefox immedia
tely.
Limitations of frame scripts
for example: nsifileinputstream nsifileoutputstream constructing a file from a string or nsifile (but file objects can be sent via message manager) htmlinpu
telement.mozsetfilenamearray (alternative: mozsetfilearray) file: uris, see bug 1187099 <...> xul and browser ui anything that tries to touch the browser ui or anything to do with xul is likely not to work in the content process.
...by default, about: pages (except for a small whi
telist) are loaded in the chrome process when browsed to from the awesomebar.
Message manager overview
if you load a frame script using the global frame message manager, the script gets loaded separa
tely into every open tab: three times, in the diagram above.
...if you load a frame script using the window message manager it gets loaded separa
tely into each tab open in that particular window.
Security best practices for Firefox front-end engineers
the canonical truth for the list of whi
telisted elements is the source code.
... appendix list of disallowed dom apis innerhtml outerhtml insertadjacenthtml() createcontextualfragment() document.write() document.wri
teln() please take a look at the repository for an updated list ...
Hacking with Bonsai
use the bonsai query tool to see what's been checked in to the tree la
tely and to look at differences between versions.
...you are either at your desk, or pageable, checking e-mail constantly, or on irc so that you can be found immedia
tely and can respond to any problems in your code.
Integrated Authentication
on older versions of windows this hash is computed using a relatively weak algorithm (see her
tel for more info on ntlm authentication).
... mozilla currently supports a whi
telist of sites that are permitted to engage in spnego authentication with the browser.
JavaScript Tips
similarly prefer document.ge
telementsbytagname(atag).item(0) != null to document.ge
telementsbytagname(atag).length > 0.
... xul also maps the class attribute, but unfortuna
tely class is a reserved identifier, so the property is named classname.
Add-on Manager
the callbacks may be called immedia
tely while the initial function is still executing or shortly after, depending on when the requested data becomes available.
...it must be passed an upda
telistener to receive information about compatibility information and new update information.
Download
you can use the downloadtarget.size property to get the actual size of the comple
tely-downloaded file once the download has succeeded.
... if the cancel() method was called but the cancellation process has not finished yet, this method waits for the cancellation to finish, then restarts the download immedia
tely.
Promise
for example, the os.file.exists function returns a promise that will eventually fulfill with a boolean: promise<boolean> exists(string path); the rejection reason may be specified separa
tely in the function's documentation, and is considered to be an error object unless otherwise specified.
... new promise(executor); parameters executor this function is invoked immedia
tely with the resolving functions as its two arguments: executor(resolve, reject); the constructor will not return until the executor has completed.
Application Translation with Mercurial
start tracking changes you make against the localization repository by
telling it that with the qnew subcommand to save these changes as patch in a mercurial queue.
...
tell mercurial to store the changes in the mercurial queue with the qref command.
Index
with that document, users can see immedia
tely two localized files in their user interface by following closely and carefully the steps to create a language pack or a binary file that is ready for installation.
... apache, infrastructure, localization, php, svn, unix first, make your project's file type decision (see localization formats for details): 40 what every mozilla translator should know internationalization, localization l10n stands for localization = l + another 10 letters + n 41 writing localizable code internationalization, localization this page
tells you about best practices and guidelines when dealing with ui code with respect to localization.
Localization technical reviews
this is something to look for, but can be difficult to diagnose immedia
tely.
...in order to ultima
tely have your revision included as an official build, your dashboards must be at 100% green.
Localization formats
can be hard to
tell what has changed .lang files historically, mozilla has used a gettext-like file to present content for localization.
...rs to edit the l10n file where they shouldn't separates localizable strings available for localizers for the rest of the code, protecting it from unintended changes disadvantage of gettext .po file needs to be compiled into a .mo file for localizer to see changes using regular diff to see changes to a file is sometimes impossible because the editing tool can save the .po file using a comple
tely different structure or order of entities.
Basics
<msup> <mi>y</mi> <mn>4</mn> </msup> </mrow> <mo>+</mo> <msup> <mi>y</mi> <mn>5</mn> </msup> </mrow> </maction> </mtd> </mtr> </mtable> </mtd> </mtr> </mtable> </math> </div> css content .control { text-decoration: none; font-weight: bold; font-size: 200%; } input { color: red; } [class="inputmath"] { border: 1px dotted; } javascript content function setselection(id,value) { document.ge
telementbyid(id).setattribute("selection",value); } function expand() { setselection("a11","2"); setselection("a12","2"); setselection("a13","2"); setselection("a21","2"); setselection("a22","2"); setselection("a23","2"); setselection("a31","2"); setselection("a32","2"); setselection("a33","2"); setselection("a41","2"); setselection("a42","2"); setselection("a43","2"); } function unex...
...pand() { setselection("a11","1"); setselection("a12","1"); setselection("a13","1"); setselection("a21","1"); setselection("a22","1"); setselection("a23","1"); setselection("a31","1"); setselection("a32","1"); setselection("a33","1"); setselection("a41","1"); setselection("a42","1"); setselection("a43","1"); } function incrementinput(inputid, increment) { var inpu
telement = document.ge
telementbyid(inputid); var size = parseint(inpu
telement.size) + increment; if (size <= 0) size = 1 inpu
telement.size = size; } and there could be more...
MathML Demo: <mspace> - space
"javascript:downdepth();" title="decrease depth">-</a> <math display="block"> <mstyle displaystyle="true"> <msqrt> <mrow> <mn>3</mn> <mspace style="background-color: yellow" id="thespace" height="0.1ex" depth="0.1ex" width="0.1em" /> <mi>x</mi> </mrow> </msqrt> </mstyle> </math> </p> javascript content var height=0; var width=0; var depth=0; function upheight() { height++; document.ge
telementbyid("thespace").setattribute("height",height+".1ex"); } function downheight() { height--; document.ge
telementbyid("thespace").setattribute("height",height+".1ex"); } function upwidth() { width++; document.ge
telementbyid("thespace").setattribute("width",width+".1em"); } function downwidth() { width--; document.ge
telementbyid("thespace").setattribute("width",width+".1em"); } functi...
...on updepth() { depth++; document.ge
telementbyid("thespace").setattribute("depth",depth+".1ex"); } function downdepth() { depth--; document.ge
telementbyid("thespace").setattribute("depth",depth+".1ex"); } ...
Mozilla Development Strategies
this puts the bug on the radar of our documentation team to ensure that once the bug is resolved, the documentation will be updated appropria
tely.
...it's easier to
tell someone set a pref, or apply a small patch, or set a #define than to apply a monster patch.
Activity Monitor, Battery Status Menu and top
(apple support documentation specifically recommends it for troubleshooting battery life problems.) unfortuna
tely "energy impact" is not a good measure for either users or software developers and it should be avoided.
...the exception is when the application is closed, in which case it disappears immedia
tely.
GPU performance
in
tel graphics performance analyzers - haven't tried.
...guides accura
tely profiling direct3d api calls (direct3d 9)- suggests avoiding normal profilers like xperf and instead measuring the time to flush the command buffer.
tools/power/rapl
tools/power/rapl (or rapl for short) is a command-line utility in the mozilla tree that periodically reads and prints all available in
tel rapl power estimates.
... windows unfortuna
tely, rapl does not work on windows, and porting it would be difficult because windows does not have apis that allow easy access to the relevant model-specific registers.
Phishing: a short definition
the ss7
telephony system is vulnerable, making eavesdropping, or rerouting text messages quite trivial.
...unfortuna
tely, some users still feel it's too tedious unlocking a phone, opening the otp app, and manually typing a few digits each time a provider requests a new token.
A guide to searching crash reports
this immedia
tely shows which moz_crash calls are being hit frequently by users.
...these results would be improved by using numeric ranges instead of individual values, but unfortuna
tely that isn't supported.
L20n HTML Bindings
in addition to the pre-defined whi
telists, any element found in the original source html is allowed in the translation as well.
...</p> the input element is not on the default whi
telist but since it's present in the source html, it is also allowed in the translation.
NSPR Poll Method
the prototype of the poll method is print16 poll_method(prfiledesc *fd, print16 in_flags, print16 *out_flags); the purpose of the poll method is to allow a layer to modify that flags that will ultima
tely be used in the call to the underlying network transport's select (or equivalent) function, and to indicate that a layer is already able to make progress in the manner suggested by the polling flags.
...on return, if (new_flags & out_flags) is nonzero, you can try pr_recv or pr_send immedia
tely.
Introduction to NSPR
nspr threads are scheduled in two separate domains: local threads are scheduled within a process only and are handled entirely by nspr, either by comple
tely emulating threads on each host operating system (os) that doesn't support threads, or by using the threading facilities of each host os that does support threads to emulate a relatively large number of local threads by using a relatively small number of native threads.
...writing the code as follows could potentially return a null reference, violating the invariant of the function: void *dequeue() { void *db; enter(monitor); if ((db = delink()) == null) { wait(condition); db = delink(); } exit(monitor); return db; } the same function would be more appropria
tely written as follows: void *dequeue() { void *db; enter(monitor); while ((db = delink()) == null) wait(condition); exit(monitor); return db; } caution: the semantics of pr_waitcondvar assume that the monitor is about to be exited.
PRLinger
description by default, pr_close returns immedia
tely, but if there are any data remaining in the socket send buffer, the system attempts to deliver the data to the peer.
... the pr_sockopt_linger socket option, with a value represented by a structure of type prlinger, makes it possible to change this default as follows: if polarity is set to pr_false, pr_close returns immedia
tely, but if there are any data remaining in the socket send buffer, the runtime attempts to deliver the data to the peer.
JSS FAQ
how can i
tell which ssl/tls ciphers jss supports?
...you can find more information in bugzilla bug 102251 ssl session cache locking issue with nt fibers how can i
tell which ssl/tls ciphers jss supports?
NSS 3.14.2 release notes
the release is available for download from https://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/nss_3_14_2_rtm/src/ for the primary nss documentation pages please visit /docs/nss new in nss 3.14.2 nss will now make use of the in
tel aes-ni and avx instruction sets for hardware-accelerated aes-gcm on 64-bit linux systems.
... new types: in certt.h cert_pi_useonlytrustanchors in secoidt.h sec_oid_ms_ext_key_usage_ctl_signing notable changes in nss 3.14.2 bug 805604 - support for aes-ni and avx accelerated aes-gcm was contributed by shay gueron of in
tel.
NSS 3.16.2.1 release notes
users are encouraged to upgrade immedia
tely.
... bugs fixed in nss 3.16.2.1 bug 1064636 - (cve-2014-1568) rsa signature forgery in nss acknowledgements the nss development team would like to thank antoine delignat-lavaud, security researcher at inria paris in team prosecco, and the advanced threat research team at in
tel security, who both independently discovered and reported this issue, for responsibly disclosing the issue by providing advance copies of their research.
NSS 3.16.5 release notes
users are encouraged to upgrade immedia
tely.
... bugs fixed in nss 3.16.5 bug 1064636 - (cve-2014-1568) rsa signature forgery in nss acknowledgements the nss development team would like to thank antoine delignat-lavaud, security researcher at inria paris in team prosecco, and the advanced threat research team at in
tel security, who both independently discovered and reported this issue, for responsibly disclosing the issue by providing advance copies of their research.
NSS 3.17.1 release notes
users are encouraged to upgrade immedia
tely.
...s 3.17.1 this bugzilla query returns all the bugs fixed in nss 3.17.1: https://bugzilla.mozilla.org/buglist.cgi?resolution=fixed&classification=components&query_format=advanced&product=nss&target_milestone=3.17.1 acknowledgements the nss development team would like to thank antoine delignat-lavaud, security researcher at inria paris in team prosecco, and the advanced threat research team at in
tel security, who both independently discovered and reported this issue, for responsibly disclosing the issue by providing advance copies of their research.
NSS 3.35 release notes
tls servers are able to handle a clienthello sta
telessly, if the client supports tls 1.3.
... this better enables sta
teless server operation.
NSS Developer Tutorial
unfortuna
tely, this can be a source of integer overflow bugs on 64-bit systems.
...unfortuna
tely, public headers may declare private functions, for historical reasons.
NSS Tools sslstrength
policy=export or policy=domestic will set your policies appropria
tely.
...you can
tell if you stepped-up, because the output will says 'using export policy', and you'll find the secret key size was 128-bits.
PKCS #11 Module Specs
parameter passing if the parameter is specified, the application/library will strip the value out, processing any outter quotes and escapes appropria
tely, and pass the parameter to the pkcs #11 library when it calls c_initialize().
... critical - if this library cannot be loaded, comple
tely fail initialization.
FC_GetOperationState
syntax ck_rv fc_getoperationstate( ck_session_handle hsession, ck_byte_ptr poperationstate, ck_ulong_ptr puloperationsta
telen ); parameters hsession [in] handle of the open session.
...puloperationsta
telen [out] pointer to ck_ulong which receives the total length (in bytes) of the operation state.
FC_SetOperationState
syntax ck_rv fc_setoperationstate( ck_session_handle hsession, ck_byte_ptr poperationstate, ck_ulong uloperationsta
telen, ck_object_handle hencryptionkey, ck_object_handle hauthenticationkey ); parameters hsession [in] handle of the open session.
...uloperationsta
telen [in] contains the total length (in bytes) of the operation state.
sslintro.html
these functions
tell the library which cipher suites are permitted by policy (for example, to comply with export restrictions).
... use ssl_forcehandshake when the socket has been prepared for a handshake but neither end has anything to say immedia
tely.
NSS Tools sslstrength
policy=export or policy=domestic will set your policies appropria
tely.
...you can
tell if you stepped-up, because the output will says 'using export policy', and you'll find the secret key size was 128-bits.
NSS tools : signtool
-e extension
tells signtool to sign only files with the given extension; for example, use -e".class" to sign only java class files.
... -z
tells signtool not to store the signing time in the digital signature.
Necko walkthrough
nshttpconnection::activate this connection is passed the transaction nshttpconnection::onoutputstreamready nshttpconnection::onsocketwritable tries to write the request data from the current transaction (mtransaction)
tells the transaction to now wait (`resumerecv) nshttpconnection::resumerecv nshttptransaction::readsegments readrequestsegment is passed to mrequeststream->readsegments - this function pointer is called and used to read the request bytes, which in turn calls ...
...note: from what i can
tell, there are some cases where the transaction is queued up to be written to the socket later if it's not writable now, or in the case of pipelining or spdy where it's done in batches.
Installing Pork
to
tell mcpp which gcc installation to integrate itself with, place the selected gcc bin dir as the first element of your path: path=/bindir/of/my/gcc:$path if you want to use a gcc that has binaries named something other than "gcc" and "g++", or you use "ccache" for you main gcc installation and want mcpp to override a separate installation, you need to pass the options "cc=gccxxx cxx=g++xxx" to "./c...
...in particular, -k
tells mcpp to add the macro annotations we use to get exact source positions.
SpiderMonkey Build Documentation
if --enable-nspr-build does not work, explicitly
tell configure where to find nspr using the --with-nspr-cflags and --with-nspr-libs configure options.
... building your application while "how to build your complete application" is clearly out of scope for this document, here are some tips that will help get you on your way: the spidermonkey developers frequently and delibera
tely change the jsapi abi.
Creating JavaScript jstest reftests
a different approach is to use the expectexitcode(exitcode) function which outputs a string: --- note: in this testcase, we expect exit code <exitcode> --- that
tells the post-processing scripts jsdriver.pl or post-process-logs.pl that the test passes if the shell or browser terminates with that exit code.
... multiple calls to expectexitcode will
tell the post-processing scripts that the test actually passed if any of the exit codes are found when the test terminates.
Functions
if a name defini
tely refers to an argument or local variable of the immedia
tely enclosing function, it can be accessed using jsop_{get,set,call}{arg,local} instructions.
...outside all functions, if a name defini
tely refers to a global for which we have seen a var, const, or function declaration, then we emit a js_defvar instruction in the script prelude and access the global using jsop_{get,set,call}gvar.
JSAPI Cookbook
ion(cx); /* do error-handling stuff here */ return true; finally // javascript try { foo(); bar(); } finally { cleanup(); } if your c/c++ cleanup code doesn't call back into the jsapi, this is straightforward: /* jsapi */ bool success = false; if (!js_callfunctionname(cx, global, "foo", 0, null, &r)) goto finally_block; /* instead of returning false immedia
tely */ if (!js_callfunctionname(cx, global, "bar", 0, null, &r)) goto finally_block; success = true; /* intentionally fall through to the finally block.
... /* jsapi */ bool success = false; if (!js_callfunctionname(cx, global, "foo", 0, null, &r)) goto finally_block; /* instead of returning false immedia
tely */ if (!js_callfunctionname(cx, global, "bar", 0, null, &r)) goto finally_block; success = true; /* intentionally fall through to the finally block.
JS_AddArgumentFormatter
the js_true passed for fromjs
tells the formatter to convert zero or more jsvals at sp to zero or more c values accessed via pointers-to-values at ap, updating both sp (via *vpp) and ap (via *app) to point past the converted arguments and their result pointers on the c stack.
... when called from js_pushargumentsva, the formatter is invoked thus: formatter(cx, "aa...", js_false, &sp, &ap); where js_false for fromjs means to wrap the c values at ap according to the format specifier and store them at sp, updating ap and sp appropria
tely.
JS_DumpHeap
the "trace kind" is a static map which
tells which layout a gc thing has.
... although this map is public, the details are comple
tely hidden.
JS_NewGlobalObject
this api provides a way for consumers to set slots atomically (immedia
tely after the global is created), before any debugger hooks are fired.
... it's unfortuna
tely on the clunky side, but that's the way the cookie crumbles.
JS_SetBranchCallback
if the callback returns js_false without raising an exception, then the javascript engine immedia
tely stops running the script with an uncatchable error.
...the callback simply increments the counter and does nothing further (returning js_true immedia
tely) unless the counter has reached the threshold value.
JS_YieldRequest
a program can call this function periodically to ensure that a long-running request does not block garbage collection indefini
tely.
... the effect is the same as a call to js_suspendrequest immedia
tely followed by a call to js_resumerequest.
Secure Development Guidelines
: dynamically allocate fd_set structs int main(void) { int i, fd; fd_set fdset; for( i = 0; i < 2000; i++) { fd = open("/dev/null", o_rdwr); } fd_set(fd, &fdset); } file i/o: race conditions operating on files can often lead to race conditions since the file system is shared with other processes you check the state of a file at one point in time and immedia
tely after the state might have changed most file name operations suffer from these race conditions, but not when performed on file descriptors file i/o: race conditions consider the following example int main(int argc, char **argv) { char *file = argv[1]; int fd; struct stat statbuf; stat(file, &statbuf); if (s_islink(statbuf.st_mode)) { bailout(“symbolic link�...
... unlock(locka); unlock(lockb); } writing secure code: good coding practices banned api list badly designed apis can often lead to vulnerabilities it’s too easy to use the api inappropria
tely for example, consider the libc string handling apis strcpy() performs no bounds checking strncpy() doesn’t always 0-terminate strncat() length parameter is very confusing banned api list examples of incorrect strncat usage buffer overflow strncat(buffer, string, sizeof(buffer)); off-by-one strncat(buffer, string, sizeof(buffer) – strlen(string)); ...
Generating GUIDs
warning: if you just want an id for your add-on, generating a guid is almost defini
tely not what you want to do.
... using the extensionname@organization.tld form is approxima
tely one thousand times easier for everyone involved.
Creating the Component Code
the registerself call allows your component to
tell xpcom exactly what it supports.
... nsicomponentregistrar methods to
tell xpcom what implementation is in the component library, call this method from registerself: ns_imethod registerfactorylocation(const nscid & aclass, const char *aclassname, const char *acontractid, nsifile *afile, const char *aloaderstr, ...
Preface
it is badly out of date, and much of what it says is either no longer remo
tely accurate, or is severely deprecated.
...those terms are either explained immedia
tely after they are cited, or else the reader is referred to a section in the book where they are described in detail.
Starting WebLock
for example, the user interface needs to be able to enable and disable the web locking functionality, see what sites are in the whi
telist, and add or remove sites from that list.
...on the macintosh platform, for example, files are represented as a triplet - two numbers and one string - so using a string on the macintosh does not adequa
tely identify files on that operating system.
Components.utils.cloneInto
same mechanism as that used in components.utils.exportfunction: // add-on script var addonscriptobject = { greetme: function() { alert("hello from add-on"); } }; contentwindow.addonscriptobject = cloneinto(addonscriptobject, contentwindow, {clonefunctions: true}); // page script var test = document.ge
telementbyid("test"); test.addeventlistener("click", function() { window.addonscriptobject.greetme(); }, false); cloning objects that contain dom elements by default, if the object you clone contains objects that are reflected from c++, such as dom elements, the cloning operation will fail with an error.
...rapreflectors:true} flag, then the object you clone is allowed to contain these objects: // add-on script var addonscriptobject = { body: contentwindow.document.body }; contentwindow.addonscriptobject = cloneinto(addonscriptobject, contentwindow, {wrapreflectors: true}); // page script var test = document.ge
telementbyid("test"); test.addeventlistener("click", function() { console.log(window.addonscriptobject.body.innerhtml); }, false); access to these objects in the target scope is subject to the normal security checks.
Components.utils.schedulePreciseGC
note: garbage collection is a very expensive operation and should only be forced when it is known to be absolu
tely necessary.
...egc(), you specify a callback that is executed in once the scheduled garbage collection has been completed: components.utils.scheduleprecisegc( function() { // this code is executed when the garbage collection has completed } ); since the garbage collection doesn't occur until some time in the future (unlike, for example, components.utils.forcegc(), which causes garbage collection immedia
tely but isn't able to collect all javascript-related memory), the callback lets you know when that's been finished.
imgIDecoderObserver
however, with decode-on-draw, the set of decode notifications can come comple
tely after the load notifications, and can come multiple times if the image is discardable.
...unfortuna
tely, this is currently the only way to signal decoding errors to consumers, and the only decoding errors that consumers care about (indeed, the only ones that they're prepared to hear about) are failures to instantiate the decoder (<img src="foo.html"> for example).
imgIRequest
status_frame_complete 0x10 the first frame has been comple
tely decoded.
...imgirequest clone( in imgidecoderobserver aobserver ); parameters aobserver return value decrementanimationconsumers()
tell the image it can forget about a request that the image animate.
mozIRegistry
introduction the title of this document is comple
tely misleading.
...the information below is intended to
tell you everything you need to know about how to do that.
mozIStorageConnection
note: the statements may be reused immedia
tely, and the statements do not need to be reset individually.
...this helps avoid disk fragmentation by letting you help sqlite make in
telligent decisions about resizing of the file.
nsICRLInfo
lastupda
telocale astring lastupdate formatted as a human readable string formatted according to the environment locale.
... nextupda
telocale astring nextupdate formatted as a human readable string formatted according to the environment locale.
nsIDOMChromeWindow
this method
tells the window manager to start dragging the window.
...if set to -1, cycles indefini
tely until window is brought into the foreground.
nsIDragService
enddragsession()
tells the drag service to end a drag session.
... startdragsession()
tells the drag service to start a drag session.
nsIEditorSpellCheck
ignorewordalloccurrences()
tells the spell checker to ignore all occurrences of the specified word when spell checking the document.
...this function allows the caller to force the default immedia
tely.
nsIFile
unfortuna
tely, an actual "move" is impossible between different volumes (disks or partitions).
... unfortuna
tely, an actual "move" is impossible between different volumes (disks or partitions).
nsILocalFile
delete_on_close may be implemented by removing the file (by path name) immedia
tely after opening it, so beware of possible races; the file should be exclusively owned by this process.
...therefore, never use these functions unless you are absolu
tely sure that the path passed to them is always ascii-only.
nsILoginManager
to create an instance, use: var loginmanager = components.classes["@mozilla.org/login-manager;1"] .getservice(components.interfaces.nsiloginmanager); method overview void addlogin(in nsilogininfo alogin); nsiautocompleteresult autocompletesearch(in astring asearchstring, in nsiautocompleteresult apreviousresult, in nsidomhtmlinpu
telement aelement); unsigned long countlogins(in astring ahostname, in astring aactionurl, in astring ahttprealm); boolean fillform(in nsidomhtmlformelement aform); void findlogins(out unsigned long count, in astring ahostname, in astring aactionurl, in astring ahttprealm, [retval, array, size_is(count)] out nsilogininfo logins); void getalldisabledhosts([optional...
... nsiautocompleteresult autocompletesearch( in astring asearchstring, in nsiautocompleteresult apreviousresult, in nsidomhtmlinpu
telement aelement ); parameters asearchstring missing description apreviousresult missing description aelement missing description return value missing description countlogins() returns the number of logins matching the specified criteria.
nsIMacDockSupport
bute('label', 'show most recent window'); macmenuitem.setattribute('id', 'mymacmenuitem'); macmenuitem.addeventlistener('command', function(){ var docksupport = cc['@mozilla.org/widget/macdocksupport;1'].getservice(ci.nsimacdocksupport); docksupport.activateapplication(true); services.wm.getmostrecentwindow(null).focus() }) macmenu.appendchild(macmenuitem); var mainpopupset = win.document.ge
telementbyid('mainpopupset'); mainpopupset.appendchild(macmenu); let dockmenuelement = macmenu; //document.ge
telementbyid("menu_mac_dockmenu");66 let nativemenu = cc["@mozilla.org/widget/standalonenativemenu;1"].createinstance(ci.nsistandalonenativemenu); console.log('dockmenuelement:', dockmenuelement); nativemenu.init(dockmenuelement); docksupport.dockmenu = nativemenu; this replaces the default...
...); macmenuitem.setattribute('label', 'show most recent window'); macmenuitem.setattribute('id', 'mymacmenuitem'); macmenuitem.addeventlistener('command', function(){ var docksupport = cc['@mozilla.org/widget/macdocksupport;1'].getservice(ci.nsimacdocksupport); docksupport.activateapplication(true); services.wm.getmostrecentwindow(null).focus() }) services.appshell.hiddendomwindow.document.ge
telementbyid('menu_mac_dockmenu').appendchild(macmenuitem) this adds the "show most recent window" menuitem from the previous example as a third item.
nsIMessenger
as far as i can
tell this isn't used or checked.
...unfortuna
tely, you must call this before navigating to a position, because calling this has the side effect of making us adjust our current history position, and not adding the loaded message to the history queue.
nsIMsgSearchSession
; boolean isstringattribute(in nsmsgsearchattribvalue attrib); void addallscopes(in nsmsgsearchscopevalue attrib); void search(in nsimsgwindow awindow); void interruptsearch(); void pausesearch(); void resumesearch(); [noscript] nsmsgsearchtype setsearchparam(in nsmsgsearchtype type, in voidptr param); [noscript] void addresul
telement(in nsmsgresul
telement element); boolean matchhdr(in nsimsgdbhdr amsghdr, in nsimsgdatabase adatabase); void addsearchhit(in nsimsgdbhdr header, in nsimsgfolder folder); attributes attribute type description searchterms nsisupportsarray readonly: numsearchterms unsigned long readonly: runningadapter nsimsgsea...
... void pausesearch(); resumesearch() void resumesearch(); setsearchparam() [noscript] nsmsgsearchtype setsearchparam(in nsmsgsearchtype type, in voidptr param); parameters type param addresul
telement() [noscript] void addresul
telement(in nsmsgresul
telement element); parameters element matchhdr() boolean matchhdr(in nsimsgdbhdr amsghdr, in nsimsgdatabase adatabase); parameters amsghdr adatabase addsearchhit() void addsearchhit(in nsimsgdbhdr header, in nsimsgfolder folder); parameters header folder ...
Component; nsIPrefBranch
if you find yourself wondering what is the maximum amount of data you can store in a string preference, consider storing data separa
tely, for example in a flat file or an sqlite database.
...if you find yourself wondering what is the maximum amount of data you can store in a string preference, consider storing data separa
tely, for example in a flat file or an sqlite database.
nsIProtocolProxyService
proxy auto config (pac) may perform a synchronous dns query, which may not return immedia
tely.
...this method is intended as a substitute for resolve when the result is not needed immedia
tely.
nsISessionStore
this method affects all tabs indiscrimina
tely.
... note: calling setbrowserstate immedia
tely replaces the current session, restoring the state of the entire application to the state passed in the astate parameter.
nsIStyleSheetService
sheets added via this api take effect on all documents, including already-loaded ones, immedia
tely.
...the removal takes effect immedia
tely, even for already-loaded documents.
nsITextInputProcessor
if you call this when there is no composition, this starts composition automatically and commits the composition with specified string immedia
tely.
...but the computation doesn't emulate the mapping of native key event handling comple
tely because it has some special cases depending on platform or selected keyboard layout.
nsITreeBoxObject
void invalidate(); void invalidatecolumn(in nsitreecolumn col); void invalidaterow(in long index); void invalidatecell(in long row, in nsitreecolumn col); void invalidaterange(in long startindex, in long endindex); void invalidatecolumnrange(in long startindex, in long endindex, in nsitreecolumn col); getrowat() a hit test that can
tell you what row the mouse is over.
... long getrowat(in long x, in long y); parameters x the x coordinate y the y coordinate getcellat() a hit test that can
tell you what cell the mouse is over.
nsIWebBrowserChrome
the implementation should reflect the value of this attribute by hiding or showing its chrome appropria
tely.
...sizebrowserto()
tells the chrome to size itself such that the browser will be the specified size.
nsIWebBrowserChromeFocus
inherits from: nsisupports last changed in gecko 1.7 method overview void focusnex
telement(); void focusprevelement(); methods focusnex
telement() set the focus at the next focusable element in the chrome.
... void focusnex
telement(); parameters none.
nsIXPConnect
deferreleasesuntilaftergarbagecollection prbool obsolete since gecko 1.9 pendingexception nsiexception constants constant value description init_js_standard_classes 1 << 0 flag_system_global_object 1 << 1 omit_components_object 1 << 2 xpc_xow_clearscope 1
tells updatexows() to clear the scope of all of the xows it finds.
... return value missing description exceptions thrown missing exception missing description native code only!evalinsandboxobject evaluate script in a sandbox, comple
tely isolated from all other running scripts.
nsIXULBrowserWindow
xpfe/appshell/public/nsixulbrowserwindow.idlscriptable provides methods that may be called from the internals of the browser area to
tell the containing xul window to update its user interface.
... setoverlink()
tells the object implementing this function what link we are currently over.
nsIXULWindow
highestz 9 methods addchildwindow()
tell this window that it has picked up a child xul window.note that xul windows do not currently track child xul windows.
... removechildwindow()
tell this window that it has lost a child xul window.
XPCOM Interface Reference
iapplicationcachenamespacensiapplicationcacheservicensiapplicationupdateservicensiarraynsiasyncinputstreamnsiasyncoutputstreamnsiasyncstreamcopiernsiasyncverifyredirectcallbacknsiauthinformationnsiauthmodulensiauthpromptnsiauthprompt2nsiauthpromptadapterfactorynsiauthpromptcallbacknsiauthpromptprovidernsiauthpromptwrappernsiautocompletecontrollernsiautocompleteinputnsiautocompleteitemnsiautocomple
telistenernsiautocompleteobservernsiautocompleteresultnsiautocompletesearchnsibadcertlistener2nsibidikeyboardnsibinaryinputstreamnsibinaryoutputstreamnsiblocklistpromptnsiblocklistservicensiboxobjectnsibrowserboxobjectnsibrowserhistorynsibrowsersearchservicensicrlinfonsicrlmanagernsicachensicachedeviceinfonsicacheentrydescriptornsicacheentryinfonsicachelistenernsicachemetadatavisitornsicacheservicens...
...sisupportsprint64nsisupportsprtimensisupportspruint8nsisupportspruint16nsisupportspruint32nsisupportspruint64nsisupportsprimitivensisupportsprioritynsisupportsstringnsisupportsvoidnsisupportsweakreferencensisyncjpakensisyncmessagesendernsitxttohtmlconvnsitaggingservicensitaskbarpreviewnsitaskbarpreviewbuttonnsitaskbarpreviewcontrollernsitaskbarprogressnsitaskbartabpreviewnsitaskbarwindowpreviewnsi
telemetrynsitextinputprocessornsitextinputprocessorcallbacknsitextinputprocessornotificationnsithreadnsithreadeventfilternsithreadinternalnsithreadmanagernsithreadobservernsithreadpoolnsithreadpoollistenernsitimernsitimercallbacknsitoolkitnsitoolkitprofilensitoolkitprofileservicensitraceablechannelnsitransactionnsitransactionlistnsitransactionlistenernsitransactionmanagernsitransferablensitransportns...
Performance
for example sqlite> explain query plan select * from moz_historyvisit v join moz_history h on v.page_id = h.id where v.visit_date > 1000000000; 0|0|table moz_historyvisit as v with index moz_historyvisit_dateindex 1|1|table moz_history as h using primary key this
tells us that it will first look up in moz_historyvisit using an index, and will then look up in moz_history using the primary key.
...unfortuna
tely, this operation cannot be controlled on a per-transaction or per-connection basis.
Reference Manual
nscomptr<t> = do_queryinterface( nsisupports* ), nscomptr<t> = do_queryinterface( nsisupports*, nsresult* ) if you can't satisfy the above promise, you can `annotate' the assignment to
tell the nscomptr it needs to call queryinterface, e.g., nscomptr<nsifoo> foo( do_queryinterface(abarptr) ); // or foo = do_queryinterface(abarptr); // ..._will_ call |queryinterface| (and therefore, |addref|) // of course, since you're calling |queryinterface|, you might need the // error result...
... } unfortuna
tely, not.
Index
77 building a thunderbird extension 4: chrome manifest extensions, thunderbird the file called chrome.manifest
tells thunderbird what packages and overlays are provided by the extension.
...you can either put the folder with the extension files directly into thunderbird's extensions folder, or you can put a file there that
tells thunderbird where your extension is located.
Adding items to the Folder Pane
the following code snippet listens for that event: let gnumbersext = { load: function gne_load() { window.removeeventlistener("load", gnumbersext.load, false); let tree = document.ge
telementbyid("foldertree"); tree.addeventlistener("maprebuild", gnumbersext._insert, false); }, _insert: function gne__insert() { // this function is called when a rebuild occurs } }; window.addeventlistener("load", gnumbersext.load, true); the structure of folder-tree-items the folder pane stores its current display data in a property called _rowmap.
...unfortuna
tely, this rebuild will occur before an extension's "load" event fires.
Access StringBundle from Overlay
unfortuna
tely adding the bundles into thunderbird isn't as easy as adding them to your xul overlay.
... the most efficient way to append these strings is by attaching them to an existing stringbundleset as such: <stringbundleset id="stringbundleset"> <stringbundle src="chrome://your_extension/locale/overlay.properties" id="your-extension-strings" /> </stringbundleset> now that your stringbundle is attached you can access it from javascript as follows: var str = document.ge
telementbyid("your-extension-strings"); //get the stringbundle object itself str.getstring("propertyname"); //get a string (and do something with it) alternative way let stringbundleservice = cc["@mozilla.org/intl/stringbundle;1"].getservice(ci.nsistringbundleservice); let bundle = stringbundleservice.createbundle("chrome://your_extension/locale/overlay.properties"); let str = bundle...
customDBHeaders Preference
ents.interfaces.nsiobserver observe: function(amsgfolder, atopic, adata) { dump("here here!"); addcustomcolumnhandler(); } } function doonceloaded(){ var observerservice = components.classes["@mozilla.org/observer-service;1"].getservice(components.interfaces.nsiobserverservice); observerservice.addobserver(createdbobserver, "msgcreatedbview", false); window.document.ge
telementbyid('foldertree').addeventlistener("select",addcustomcolumnhandler,false); } window.addeventlistener("load",doonceloaded,false); dump(" ~ ~ ~ ~ end superfluous ~ ~ ~ ~ \n"); important be aware that only messages that are added to the .msf database after the customdbheaders pref is set will have the corresponding string property set on the msghdr.
.../ chrome.manifest chrome/content/ chrome/content/superfluous.js chrome/content/superfluous_overlay.xul install.rdf adding: chrome/ (stored 0%) adding: chrome.manifest (deflated 44%) adding: chrome/content/ (stored 0%) adding: chrome/content/superfluous.js (deflated 57%) adding: chrome/content/superfluous_overlay.xul (deflated 44%) adding: install.rdf (deflated 50%) end result ultima
tely, you want to be able to compose a message like this: and see the superfluous column displayed in your inbox like this: thanks many thanks go out to the thunderbird developers for the fine product that it is.
Using the Multiple Accounts API
relevant api calls: nsimsgaccount nsimsgaccountmanager.createaccount() nsimsgaccount nsimsgaccountmanager.getaccount(in string key) nsimsgincomingserver nsimsgaccountmanager.createincomingserver(in string type) nsimsgincomingserver nsimsgaccountmanager.getincomingserver(in string key) smtp servers smtp servers are kept separa
tely from all the other account management stuff.
... preference: mail.server.server.max_cached_connections - integer, max number of connections left open to the server preference: mail.server.server.empty_trash_threshhold integer, (should not be imap-specific) max k of wasted diskspace before we purge a folder preference: mail.server.server.delete_model - integer, delete model (move to trash, imap delete, purge immedia
tely, not sure of values) preference: mail.server.server.timeout - integer, number of minutes a connection is idle before we drop it preference: mail.server.server.capability - list of capabilities of this server preference: mail.server.server.namespace.public - the server's namespace for public folders preference: mail.server.server.namespace.personal - the server's namespace for per...
Working with data
creating uninitialized cdata objects there are three forms of the syntax for creating cdata objects without immedia
tely assigning them a value: var mycdataobj = new type; var mycdataobj = new type(); var mycdataobj = type(); these all do the same thing: they return a new cdata object of the specified type, whose data buffer has been populated entirely with zeroes.
... 64-bit integers while most numeric types in js-ctypes are represented by standard javascript number objects, 64-bit integers cannot all be represented accura
tely by this type.
Drawing and Event Handling - Plugins
« previousnext » this chapter
tells how to determine whether a plug-in instance is windowed or windowless, how to draw and redraw plug-ins, and how to handle plug-in events.
... typically, the browser calls npp_setwindow after creating the instance so that the plug-in can begin drawing immedia
tely.
Plug-in Side Plug-in API - Plugins
npp_destroystream
tells the plug-in that a stream is about to be closed or destroyed.
... npp_setwindow
tells the plug-in when a window is created, moved, sized, or destroyed.
Accessibility Inspector - Firefox Developer Tools
assistive technologies like screenreaders use this information to find out what's on a web page,
tell their users what's there, and enable them to interact with the page.
...ch are detailed below: context menu options an extra context menu option is added, both for the general context menu on the web page when right/ctrl + clicking a ui feature, and the html pane of the page inspector when right/ctrl + clicking a dom element: when you choose the inspect accessibility properties/show accessibility properties context menu options, the accessibility tab is immedia
tely opened to show the corresponding accessibility tree item and its properties.
Source map errors - Firefox Developer Tools
this message will show an error message, the resource url, and the source map url: here, the resource url
tells us that bundle.js mentions a source map, and the source map url
tells us where to find the source map data (in this case, relative to the resource).
... the error
tells us that the source map is not json data — so we're serving the wrong file.
Debugger.Object - Firefox Developer Tools
for example: function f() {} // display name: f (the given name) var g = function () {}; // display name: g o.p = function () {}; // display name: o.p var q = { r: function () {} // display name: q.r }; note that the display name may not be a proper javascript identifier, or even a proper expression: we attempt to find helpful names even when the function is not immedia
tely assigned as the value of some variable or property.
...ifvalue is a primitive, we return it unchanged; ifvalue is an object, we return the debugger.object instance representing that object, wrapped appropria
tely for use in this debugger.object’s referent’s compartment.
Debugger.Object - Firefox Developer Tools
for example: function f() {} // display name: f (the given name) var g = function () {}; // display name: g o.p = function () {}; // display name: o.p var q = { r: function () {} // display name: q.r }; note that the display name may not be a proper javascript identifier, or even a proper expression: we attempt to find helpful names even when the function is not immedia
tely assigned as the value of some variable or property.
...ifvalue is a primitive, we return it unchanged; ifvalue is an object, we return the debugger.object instance representing that object, wrapped appropria
tely for use in this debugger.object's referent's compartment.
The Firefox JavaScript Debugger - Firefox Developer Tools
you can use it to debug code running locally in firefox or running remo
tely, for example on an android device running firefox for android.
...there are multiple ways to
tell the debugger how and when to pause: set a breakpoint set a conditional breakpoint set an xhr breakpoint set event listener breakpoints break on exceptions use watchpoints for property reads and writes break on dom mutation disable breakpoints control execution what can you do after execution pauses?
Index - Firefox Developer Tools
65 inspect and select colors guide, inspector, tools in the css pane's rules view, if a rule contains a color value, you'll see a sample of the color next to the value: 66 open the inspector guide, inspector, tools there are two main ways to open the inspector: 67 reposition elements in the page starting in firefox 48 you can move absolu
tely positioned elements by dragging them around the page.
...however, you can
tell the debugger to ignore the details of selected sources.
Allocations - Firefox Developer Tools
this is
telling us that, of the 8904 allocations seen in signallater(), all but three came through the removeinner() branch.
...while gc events like this are executing, the javascript engine must be paused, so your program is suspended and will be comple
tely unresponsive.
Waterfall - Firefox Developer Tools
gc is relevant to performance because while it's running the javascript engine must be paused, so your program is suspended and will be comple
tely unresponsive.
... for example, consider code like this: var timerbutton = document.ge
telementbyid("timer"); timerbutton.addeventlistener("click", handleclick, false); function handleclick() { console.time("timer"); runtimer(1000).then(timerfinished); } function timerfinished() { console.timeend("timer"); console.log("ready!"); } function runtimer(t) { return new promise(function(resolve) { settimeout(resolve, t); }); } the waterfall will display a marker for the p...
Responsive Design Mode - Firefox Developer Tools
now when you change such settings for the first time, you are given a warning message that
tells you these reloads are no longer automatic, and informed about how you can make them automatic.
...in responsive design mode, you can instruct the browser to emulate, very approxima
tely, the characteristics of various different types of networks.
Style Editor - Firefox Developer Tools
any changes you make are immedia
tely applied to the page.
... editing original sources you can also edit the original sources in the style editor and see the results applied to the page immedia
tely.
The JavaScript input interpreter - Firefox Developer Tools
for example, if you type: function foo() { and then enter, the console does not immedia
tely execute the input, but behaves as if you had pressed shift+enter , so you can finish entering the function definition.
...there are three ways to select an iframe using cd(): you can pass the iframe dom element: var frame = document.ge
telementbyid("frame1"); cd(frame); you can pass a css selector that matches the iframe: cd("#frame1"); you can pass the iframe's global window object: var frame = document.ge
telementbyid("frame1"); cd(frame.contentwindow); to switch the context back to the top-level window, call cd() with no arguments: cd(); for example, suppose we have a document that embeds an iframe: <!doctype html> <html...
Animation.onfinish - Web APIs
the finish event occurs when the animation completes naturally, as well as when the animation.finish() method is called to immedia
tely cause the animation to finish up.
...here is one instance where we add pointer events back to an element after its opacity animation has faded it in: // add an animation to the game's ending credits var endingui = document.ge
telementbyid("ending-ui"); var bringui = endingui.animate(keysfade, timingfade); // pause said animation's credits bringui.pause(); // this function removes pointer events on the credits.
AudioBufferSourceNode - Web APIs
fortuna
tely, these nodes are very inexpensive to create, and the actual audiobuffers can be reused for multiple plays of the sound.
... audiobuffersourcenode.start() used to schedule playback of the audio data contained in the buffer, or to begin playback immedia
tely.
AudioContext.createMediaElementSource() - Web APIs
e.pagey : event.clienty + (document.documen
telement.scrolltop ?
... document.documen
telement.scrolltop : document.body.scrolltop); gainnode.gain.value = cury/height; } // connect the audiobuffersourcenode to the gainnode // and the gainnode to the destination, so we can play the // music and adjust the volume using the mouse cursor source.connect(gainnode); gainnode.connect(audioctx.destination); note: as a consequence of calling createmediaelementsource(), audio playback from the htmlmediaelement will be re-routed into the processing graph of the audiocontext.
AudioScheduledSourceNode.start() - Web APIs
if no time is specified, then the sound begins playing immedia
tely.
...a value of 0 (or omitting the when parameter entirely) causes the sound to start playback immedia
tely.
AudioScheduledSourceNode.stop() - Web APIs
if no time is specified, then the sound stops playing immedia
tely.
...omitting this parameter, specifying a value of 0, or passing a negative value causes the sound to stop playback immedia
tely.
BaseAudioContext.createChannelSplitter() - Web APIs
the createchannelsplitter() method of the baseaudiocontext interface is used to create a channelsplitternode, which is used to access the individual channels of an audio stream and process them separa
tely.
... syntax baseaudiocontext.createchannelsplitter(numberofoutputs); parameters numberofoutputs the number of channels in the input audio stream that you want to output separa
tely; the default is 6 if this parameter is not specified.
Battery Status API - Web APIs
navigator.getbattery().then(function(battery) { function updateallbatteryinfo(){ updatechargeinfo(); upda
televelinfo(); updatecharginginfo(); updatedischarginginfo(); } updateallbatteryinfo(); battery.addeventlistener('chargingchange', function(){ updatechargeinfo(); }); function updatechargeinfo(){ console.log("battery charging?
..."yes" : "no")); } battery.addeventlistener('levelchange', function(){ upda
televelinfo(); }); function upda
televelinfo(){ console.log("battery level: " + battery.level * 100 + "%"); } battery.addeventlistener('chargingtimechange', function(){ updatecharginginfo(); }); function updatecharginginfo(){ console.log("battery charging time: " + battery.chargingtime + " seconds"); } battery.addeventlistener('dischargingtimechange', function(){ updatedischarginginfo(); }); function updatedischarginginfo(){ console.log("battery discharging time: " + battery.dischargingtime + " seconds"); } }); see also the example in the specification.
CanvasPattern.setTransform() - Web APIs
html <canvas id="canvas"></canvas> <svg id="svg1"></svg> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var svg1 = document.ge
telementbyid('svg1'); var matrix = svg1.createsvgmatrix(); var img = new image(); img.src = 'https://mdn.mozillademos.org/files/222/canvas_createpattern.png'; img.onload = function() { var pattern = ctx.createpattern(img, 'repeat'); pattern.settransform(matrix.rotate(-45).scale(1.5)); ctx.fillstyle = pattern; ...
.../div> <textarea id="code" class="playable-code" style="height:120px"> var img = new image(); img.src = 'https://mdn.mozillademos.org/files/222/canvas_createpattern.png'; img.onload = function() { var pattern = ctx.createpattern(img, 'repeat'); pattern.settransform(matrix.rotate(-45).scale(1.5)); ctx.fillstyle = pattern; ctx.fillrect(0, 0, 400, 400); };</textarea> var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var textarea = document.ge
telementbyid('code'); var reset = document.ge
telementbyid('reset'); var edit = document.ge
telementbyid('edit'); var code = textarea.value; var svg1 = document.ge
telementbyid('svg1'); var matrix = svg1.createsvgmatrix(); function drawcanvas() { ctx.clearrect(0, 0, canvas.width, canvas.height); eval(textarea.valu...
CanvasRenderingContext2D.addHitRegion() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); canvas.addeventlistener('mousemove', function(event) { if(event.region) { alert('ouch, my eye :('); } }); ctx.beginpath(); ctx.arc(100, 100, 75, 0, 2 * math.pi); ctx.linewidth = 5; ctx.stroke(); // eyes ctx.beginpath(); ctx.arc(70, 80, 10, 0, 2 * math.pi); ctx.arc(130, 80, 10, 0, 2 * math.pi); ctx.fill(); ctx.addhitregion({id: "e...
...e" style="height:250px"> ctx.beginpath(); ctx.arc(100, 100, 75, 0, 2 * math.pi, false); ctx.linewidth = 5; ctx.stroke(); // eyes ctx.beginpath(); ctx.arc(70, 80, 10, 0, 2 * math.pi, false); ctx.arc(130, 80, 10, 0, 2 * math.pi, false); ctx.fill(); ctx.addhitregion({id: "eyes"}); // mouth ctx.beginpath(); ctx.arc(100, 110, 50, 0, math.pi, false); ctx.stroke();</textarea> var canvas = document.ge
telementbyid("canvas"); var ctx = canvas.getcontext("2d"); var textarea = document.ge
telementbyid("code"); var reset = document.ge
telementbyid("reset"); var edit = document.ge
telementbyid("edit"); var code = textarea.value; function drawcanvas() { ctx.clearrect(0, 0, canvas.width, canvas.height); eval(textarea.value); } reset.addeventlistener("click", function() { textarea.value = code; dra...
CanvasRenderingContext2D.bezierCurveTo() - Web APIs
html <canvas id="canvas"></canvas> javascript // define canvas and context const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // define the points as {x, y} let start = { x: 50, y: 20 }; let cp1 = { x: 230, y: 30 }; let cp2 = { x: 150, y: 80 }; let end = { x: 250, y: 100 }; // cubic bézier curve ctx.beginpath(); ctx.moveto(start.x, start.y); ctx.beziercurveto(cp1.x, cp1.y, cp2.x, cp2.y, end.x, end.y); ctx.stroke(); // start and end points ctx...
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(30, 30); ctx.beziercurveto(120,160, 180,10, 220,140); ctx.stroke(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.beziercurveto' in that specification.
CanvasRenderingContext2D.clearRect() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.clearrect(0, 0, canvas.width, canvas.height); erasing part of a canvas this example draws a blue triangle on top of a yellowish background.
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // draw yellow background ctx.beginpath(); ctx.fillstyle = '#ff6'; ctx.fillrect(0, 0, canvas.width, canvas.height); // draw blue triangle ctx.beginpath(); ctx.fillstyle = 'blue'; ctx.moveto(20, 20); ctx.lineto(180, 20); ctx.lineto(130, 130); ctx.closepath(); ctx.fill(); // clear part of the canvas ctx.clearrect(10, 10, 120, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingc...
CanvasRenderingContext2D.clip() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // create circular clipping region ctx.beginpath(); ctx.arc(100, 75, 50, 0, math.pi * 2); ctx.clip(); // draw stuff that gets clipped ctx.fillstyle = 'blue'; ctx.fillrect(0, 0, canvas.width, canvas.height); ctx.fillstyle = 'orange'; ctx.fillrect(0, 0, 100, 100); result specifying a path and a fillrule this example saves two rectangl...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // create clipping path let region = new path2d(); region.rect(80, 10, 20, 130); region.rect(40, 50, 100, 50); ctx.clip(region, "evenodd"); // draw stuff that gets clipped ctx.fillstyle = 'blue'; ctx.fillrect(0, 0, canvas.width, canvas.height); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.clip' in that specification.
CanvasRenderingContext2D.closePath() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(20, 140); // move pen to bottom-left corner ctx.lineto(120, 10); // line to top corner ctx.lineto(220, 140); // line to bottom-right corner ctx.closepath(); // line to bottom-left corner ctx.stroke(); result closing just one sub-path this example draws a smiley face consisting of three disconnec...
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.arc(240, 20, 40, 0, math.pi); ctx.moveto(100, 20); ctx.arc(60, 20, 40, 0, math.pi); ctx.moveto(215, 80); ctx.arc(150, 80, 65, 0, math.pi); ctx.closepath(); ctx.linewidth = 6; ctx.stroke(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.closepath' in that specification.
CanvasRenderingContext2D.createImageData() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const imagedata = ctx.createimagedata(100, 50); console.log(imagedata); // imagedata { width: 100, height: 50, data: uint8clampedarray[20000] } filling a blank imagedata object this example creates and fills a new imagedata object with purple pixels.
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const imagedata = ctx.createimagedata(100, 100); // iterate through every pixel for (let i = 0; i < imagedata.data.length; i += 4) { // modify pixel data imagedata.data[i + 0] = 190; // r value imagedata.data[i + 1] = 0; // g value imagedata.data[i + 2] = 210; // b value imagedata.data[i + 3] = 255; // a value } // draw image data to the canvas ctx.putimagedata(imagedata, 20, 20); result more examples for more examples using createimagedata()...
CanvasRenderingContext2D.drawImage() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const image = document.ge
telementbyid('source'); image.addeventlistener('load', e => { ctx.drawimage(image, 33, 71, 104, 124, 21, 20, 87, 104); }); result understanding source element size the drawimage() method uses the source element's intrinsic size in css pixels when drawing.
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const image = new image(60, 45); // using optional size for image image.onload = drawimageactualsize; // draw when image has loaded // load an image of intrinsic size 300x227 in css pixels image.src = 'https://udn.realityripple.com/samples/db/f374e9c6fc.jpg'; function drawimageactualsize() { // use the intrinsic size of image in css pi...
CanvasRenderingContext2D.ellipse() - Web APIs
html <canvas id="canvas" width="200" height="200"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // draw the ellipse ctx.beginpath(); ctx.ellipse(100, 100, 50, 75, math.pi / 4, 0, 2 * math.pi); ctx.stroke(); // draw the ellipse's line of reflection ctx.beginpath(); ctx.setlinedash([5, 5]); ctx.moveto(0, 200); ctx.lineto(200, 0); ctx.stroke(); result various elliptical arcs this example creates three elliptical paths with varyin...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.fillstyle = 'red'; ctx.beginpath(); ctx.ellipse(60, 75, 50, 30, math.pi * .25, 0, math.pi * 1.5); ctx.fill(); ctx.fillstyle = 'blue'; ctx.beginpath(); ctx.ellipse(150, 75, 50, 30, math.pi * .25, 0, math.pi); ctx.fill(); ctx.fillstyle = 'green'; ctx.beginpath(); ctx.ellipse(240, 75, 50, 30, math.pi * .25, 0, math.pi, true); ctx.fill(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.ellipse' in that specification.
CanvasRenderingContext2D.fill() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.rect(10, 10, 150, 100); ctx.fill(); result specifying a path and a fillrule this example saves some intersecting lines to a path2d object.
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // create path let region = new path2d(); region.moveto(30, 90); region.lineto(110, 20); region.lineto(240, 130); region.lineto(60, 130); region.lineto(190, 20); region.lineto(270, 90); region.closepath(); // fill path ctx.fillstyle = 'green'; ctx.fill(region, 'evenodd'); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.fill' in that specification.
CanvasRenderingContext2D.fillRect() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.fillstyle = 'green'; ctx.fillrect(20, 10, 150, 100); result filling the whole canvas this code snippet fills the entire canvas with a rectangle.
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.fillrect(0, 0, canvas.width, canvas.height); specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.fillrect' in that specification.
CanvasRenderingContext2D.fillStyle - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.fillstyle = 'blue'; ctx.fillrect(10, 10, 100, 100); result creating multiple fill colors using loops in this example, we use two for loops to draw a grid of rectangles, each having a different fill color.
... <canvas id="canvas" width="150" height="150"></canvas> const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); for (let i = 0; i < 6; i++) { for (let j = 0; j < 6; j++) { ctx.fillstyle = `rgb( ${math.floor(255 - 42.5 * i)}, ${math.floor(255 - 42.5 * j)}, 0)`; ctx.fillrect(j * 25, i * 25, 25, 25); } } the result looks like this: screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontex...
CanvasRenderingContext2D.fillText() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = '50px serif'; ctx.filltext('hello world', 50, 90); this code obtains a reference to the <canvas>, then gets a reference to its 2d graphics context.
... html <canvas id="canvas" width="400" height="150"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = '50px serif'; ctx.filltext('hello world', 50, 90, 140); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.filltext' in that specification.
CanvasRenderingContext2D.getLineDash() - Web APIs
syntax ctx.getlinedash(); return value an array of numbers that specify distances to alterna
tely draw a line and a gap (in coordinate space units).
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.setlinedash([10, 20]); console.log(ctx.getlinedash()); // [10, 20] // draw a dashed line ctx.beginpath(); ctx.moveto(0, 50); ctx.lineto(300, 50); ctx.stroke(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.getlinedash' in that specifica...
CanvasRenderingContext2D.isPointInPath() - Web APIs
html <canvas id="canvas"></canvas> <p>in path: <code id="result">false</code></p> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const result = document.ge
telementbyid('result'); ctx.rect(10, 10, 100, 100); ctx.fill(); result.innertext = ctx.ispointinpath(30, 70); result checking a point in the specified path whenever you move the mouse, this example checks whether the cursor is in a circular path2d path.
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // create circle const circle = new path2d(); circle.arc(150, 75, 50, 0, 2 * math.pi); ctx.fillstyle = 'red'; ctx.fill(circle); // listen for mouse moves canvas.addeventlistener('mousemove', function(event) { // check whether point is inside circle if (ctx.ispointinpath(circle, event.offsetx, event.offsety)) { ctx.fillstyle = 'green'; } else { ctx.fillstyle = 'red'; } // draw circle ctx.clearrect(0, 0, canvas.width, canvas.height); ctx.fill(circle); }); result specifications specification status comment html living standardthe definition of 'canv...
CanvasRenderingContext2D.isPointInStroke() - Web APIs
html <canvas id="canvas"></canvas> <p>in stroke: <code id="result">false</code></p> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const result = document.ge
telementbyid('result'); ctx.rect(10, 10, 100, 100); ctx.stroke(); result.innertext = ctx.ispointinstroke(50, 10); result checking a point in the specified path whenever you move the mouse, this example checks whether the cursor is in the stroke of an elliptical path2d path.
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // create ellipse const ellipse = new path2d(); ellipse.ellipse(150, 75, 40, 60, math.pi * .25, 0, 2 * math.pi); ctx.linewidth = 25; ctx.strokestyle = 'red'; ctx.fill(ellipse); ctx.stroke(ellipse); // listen for mouse moves canvas.addeventlistener('mousemove', function(event) { // check whether point is inside ellipse's stroke if (ctx.ispointinstroke(ellipse, event.offsetx, event.offsety)) { ctx.strokestyle = 'green'; } else { ctx.strokestyle = 'red'; } // draw ellipse ctx.clearrect(0, 0, canvas.width, canvas.height); ctx.fill(ellipse); ctx.stroke(ellipse); }); ...
CanvasRenderingContext2D.lineDashOffset - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.setlinedash([4, 16]); // dashed line with no offset ctx.beginpath(); ctx.moveto(0, 50); ctx.lineto(300, 50); ctx.stroke(); // dashed line with offset of 4 ctx.beginpath(); ctx.strokestyle = 'red'; ctx.linedashoffset = 4; ctx.moveto(0, 100); ctx.lineto(300, 100); ctx.stroke(); result the line with a dash offset is drawn in red.
... html <canvas id="canvas"></canvas> const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let offset = 0; function draw() { ctx.clearrect(0, 0, canvas.width, canvas.height); ctx.setlinedash([4, 2]); ctx.linedashoffset = -offset; ctx.strokerect(10, 10, 100, 100); } function march() { offset++; if (offset > 16) { offset = 0; } draw(); settimeout(march, 20); } march(); specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d...
CanvasRenderingContext2D.lineJoin - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.linewidth = 20; ctx.linejoin = 'round'; ctx.beginpath(); ctx.moveto(20, 20); ctx.lineto(190, 100); ctx.lineto(280, 20); ctx.lineto(280, 150); ctx.stroke(); result comparison of line joins the example below draws three different paths, demonstrating each of the three linejoin options.
... <canvas id="canvas" width="150" height="150"></canvas> var ctx = document.ge
telementbyid('canvas').getcontext('2d'); var linejoin = ['round', 'bevel', 'miter']; ctx.linewidth = 10; for (let i = 0; i < linejoin.length; i++) { ctx.linejoin = linejoin[i]; ctx.beginpath(); ctx.moveto(-5, 5 + i * 40); ctx.lineto(35, 45 + i * 40); ctx.lineto(75, 5 + i * 40); ctx.lineto(115, 45 + i * 40); ctx.lineto(155, 5 + i * 40); ctx.stroke(); } screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.linejoin' in that specification.
CanvasRenderingContext2D.lineTo() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); // start a new path ctx.moveto(30, 50); // move the pen to (30, 50) ctx.lineto(150, 100); // draw a line to (150, 100) ctx.stroke(); // render the path result drawing connected lines each call of lineto() (and similar methods) automatically adds to the current sub-path, which means that all the line...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.moveto(90, 130); ctx.lineto(95, 25); ctx.lineto(150, 80); ctx.lineto(205, 25); ctx.lineto(210, 130); ctx.linewidth = 15; ctx.stroke(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.lineto' in that specification.
CanvasRenderingContext2D.quadraticCurveTo() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // quadratic bézier curve ctx.beginpath(); ctx.moveto(50, 20); ctx.quadraticcurveto(230, 30, 50, 100); ctx.stroke(); // start and end points ctx.fillstyle = 'blue'; ctx.beginpath(); ctx.arc(50, 20, 5, 0, 2 * math.pi); // start point ctx.arc(50, 100, 5, 0, 2 * math.pi); // end point ctx.fill(); // control point ctx.fillstyle = 'red'; ...
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(20, 110); ctx.quadraticcurveto(230, 150, 250, 20); ctx.stroke(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.quadraticcurveto' in that specification.
CanvasRenderingContext2D.resetTransform() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // draw a rotated rectangle ctx.rotate(45 * math.pi / 180); ctx.fillrect(60, 0, 100, 30); // reset transformation matrix to the identity matrix ctx.resettransform(); result continuing with a regular matrix whenever you're done drawing transformed shapes, you should call resettransform() before rendering anything else.
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // skewed rectangles ctx.transform(1, 0, 1.7, 1, 0, 0); ctx.fillstyle = 'gray'; ctx.fillrect(40, 40, 50, 20); ctx.fillrect(40, 90, 50, 20); // non-skewed rectangles ctx.resettransform(); ctx.fillstyle = 'red'; ctx.fillrect(40, 40, 50, 20); ctx.fillrect(40, 90, 50, 20); result the skewed rectangles are gray, and the non-skewed rectangles are red.
CanvasRenderingContext2D.rotate() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // point of transform origin ctx.arc(0, 0, 5, 0, 2 * math.pi); ctx.fillstyle = 'blue'; ctx.fill(); // non-rotated rectangle ctx.fillstyle = 'gray'; ctx.fillrect(100, 0, 80, 20); // rotated rectangle ctx.rotate(45 * math.pi / 180); ctx.fillstyle = 'red'; ctx.fillrect(100, 0, 80, 20); // reset transformation matrix to the identity matrix ...
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // non-rotated rectangle ctx.fillstyle = 'gray'; ctx.fillrect(80, 60, 140, 30); // matrix transformation ctx.translate(150, 75); ctx.rotate(math.pi / 2); ctx.translate(-150, -75); // rotated rectangle ctx.fillstyle = 'red'; ctx.fillrect(80, 60, 140, 30); result the non-rotated rectangle is gray, and the rotated rectangle is red.
CanvasRenderingContext2D.scale() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // scaled rectangle ctx.scale(9, 3); ctx.fillstyle = 'red'; ctx.fillrect(10, 10, 8, 20); // reset current transformation matrix to the identity matrix ctx.settransform(1, 0, 0, 1, 0, 0); // non-scaled rectangle ctx.fillstyle = 'gray'; ctx.fillrect(10, 10, 8, 20); result the scaled rectangle is red, and the non-scaled rectangle is gray...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.scale(-1, 1); ctx.font = '48px serif'; ctx.filltext('hello world!', -280, 90); ctx.settransform(1, 0, 0, 1, 0, 0); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.scale' in that specification.
CanvasRenderingContext2D.scrollPathIntoView() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.fillrect(10, 10, 30, 30); ctx.scrollpathintoview(); edit the code below to see your changes update live in the canvas: playable code <canvas id="canvas" width="400" height="200" class="playable-canvas"> <input id="button" type="range" min="1" max="12"> </canvas> <div class="playable-buttons"> <input id="edit" ty...
...pe="button" value="edit" /> <input id="reset" type="button" value="reset" /> </div> <textarea id="code" class="playable-code"> ctx.beginpath(); ctx.rect(10, 10, 30, 30); ctx.scrollpathintoview();</textarea> var canvas = document.ge
telementbyid("canvas"); var ctx = canvas.getcontext("2d"); var textarea = document.ge
telementbyid("code"); var reset = document.ge
telementbyid("reset"); var edit = document.ge
telementbyid("edit"); var code = textarea.value; function drawcanvas() { ctx.clearrect(0, 0, canvas.width, canvas.height); eval(textarea.value); } reset.addeventlistener("click", function() { textarea.value = code; drawcanvas(); }); edit.addeventlistener("click", function() { textarea.focus(); }) textarea.addeventlistener("input", drawcanvas); window.addeventlistener("load", d...
CanvasRenderingContext2D.strokeRect() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.strokestyle = 'green'; ctx.strokerect(20, 10, 160, 100); result applying various context settings this example draws a rectangle with a drop shadow and thick, beveled outlines.
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.shadowcolor = '#d53'; ctx.shadowblur = 20; ctx.linejoin = 'bevel'; ctx.linewidth = 15; ctx.strokestyle = '#38f'; ctx.strokerect(30, 30, 160, 90); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.strokerect' in that specification.
CanvasRenderingContext2D.strokeStyle - Web APIs
html <canvas id="canvas"></canvas> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.strokestyle = 'blue'; ctx.strokerect(10, 10, 100, 100); result creating multiple stroke colors using loops in this example, we use two for loops and the arc() method to draw a grid of circles, each having a different stroke color.
...(the red channel has a fixed value.) <canvas id="canvas" width="150" height="150"></canvas> var ctx = document.ge
telementbyid('canvas').getcontext('2d'); for (let i = 0; i < 6; i++) { for (let j = 0; j < 6; j++) { ctx.strokestyle = `rgb( 0, ${math.floor(255 - 42.5 * i)}, ${math.floor(255 - 42.5 * j)})`; ctx.beginpath(); ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, math.pi * 2, true); ctx.stroke(); } } the result looks like this: screenshotlive sample specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.strokestyle' in that...
CanvasRenderingContext2D.strokeText() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = '50px serif'; ctx.stroketext('hello world', 50, 90); this code obtains a reference to the <canvas>, then gets a reference to its 2d graphics context.
... html <canvas id="canvas" width="400" height="150"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = '50px serif'; ctx.stroketext('hello world', 50, 90, 140); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.stroketext' in that specification.
CanvasRenderingContext2D.textAlign - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); canvas.width = 350; const ctx = canvas.getcontext('2d'); const x = canvas.width / 2; ctx.beginpath(); ctx.moveto(x, 0); ctx.lineto(x, canvas.height); ctx.stroke(); ctx.font = '30px serif'; ctx.textalign = 'left'; ctx.filltext('left-aligned', x, 40); ctx.textalign = 'center'; ctx.filltext('center-aligned', x, 85); ctx.textalign = 'right'; ctx.filltext('right-aligned', x, 1...
... html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = '30px serif'; ctx.direction = 'ltr'; ctx.textalign = 'start'; ctx.filltext('start-aligned', 0, 50); ctx.textalign = 'end'; ctx.filltext('end-aligned', canvas.width, 120); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.textalign' in that specification.
A basic ray-caster - Web APIs
so every update, the raycaster looks to see if you've pressed any keys la
tely, to conserve calculations by not casting if you're idle.
... also, it leaves a lot to be desired in terms of trying to be any sort of game engine—there are no wall textures, no sprites, no doors, not even any
teleporters to get to another level.
Manipulating video using canvas - Web APIs
var processor; processor.doload = function doload() { this.video = document.ge
telementbyid('video'); this.c1 = document.ge
telementbyid('c1'); this.ctx1 = this.c1.getcontext('2d'); this.c2 = document.ge
telementbyid('c2'); this.ctx2 = this.c2.getcontext('2d'); let self = this; this.video.addeventlistener('play', function() { self.width = self.video.videowidth / 2; self.height = self.video.videoheight / 2; self.timercallback(); ...
... processor.timercallback = function timercallback() { if (this.video.paused || this.video.ended) { return; } this.computeframe(); let self = this; settimeout(function() { self.timercallback(); }, 0); }, the first thing the callback does is check to see if the video is even playing; if it's not, the callback returns immedia
tely without doing anything.
Canvas API - Web APIs
html <canvas id="canvas"></canvas> javascript the document.ge
telementbyid() method gets a reference to the html <canvas> element.
... const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.fillstyle = 'green'; ctx.fillrect(10, 10, 150, 100); result reference htmlcanvaselement canvasrenderingcontext2d canvasgradient canvasimagesource canvaspattern imagebitmap imagedata renderingcontext textmetrics offscreencanvas path2d imagebitmaprenderingcontext note: the interfaces related to the webglrenderingc...
ChannelMergerNode - Web APIs
this is useful for accessing each channels separa
tely, e.g.
... for performing channel mixing where gain must be separa
tely controlled on each channel.
ChannelSplitterNode - Web APIs
this is useful for accessing each channel separa
tely, e.g.
... for performing channel mixing where gain must be separa
tely controlled on each channel.
CharacterData - Web APIs
nondocumenttypechildnode.nex
telementsibling read only returns the element immedia
tely following the specified one in its parent's children list, or null if the specified element is the last one in the list.
... nondocumenttypechildnode.previouselementsibling read only returns the element immedia
tely prior to the specified one in its parent's children list, or null if the specified element is the first one in the list.
ContentIndex.getAll() - Web APIs
async function createreadinglist() { // access our service worker registration const registration = await navigator.serviceworker.ready; // get our index entries const entries = await registration.index.getall(); // create a containing element const readinglis
telem = document.createelement('div'); // test for entries if (!array.length) { // if there are no entries, display a message const message = document.createelement('p'); message.innertext = 'you currently have no articles saved for offline reading.' readinglis
telem.append(message); } else { // if entries are present, display in a list of links to the content const ...
...lis
telem = document.createelement('ul'); for (const entry of entries) { const listitem = document.createelement('li'); const anchorelem = document.createelement('a'); anchorelem.innertext = entry.title; anchorelem.setattribute('href', entry.url); lis
telem.append(listitem); } readinglis
telem.append(lis
telem); } } specifications specification status comment unknownthe definition of 'getall' in that specification.
ContentIndex - Web APIs
async function createreadinglist() { // access our service worker registration const registration = await navigator.serviceworker.ready; // get our index entries const entries = await registration.index.getall(); // create a containing element const readinglis
telem = document.createelement('div'); // test for entries if (!array.length) { // if there are no entries, display a message const message = document.createelement('p'); message.innertext = 'you currently have no articles saved for offline reading.' readinglis
telem.append(message); } else { // if entries are present, display in a list of links to the content const ...
...lis
telem = document.createelement('ul'); for (const entry of entries) { const listitem = document.createelement('li'); const anchorelem = document.createelement('a'); anchorelem.innertext = entry.title; anchorelem.setattribute('href', entry.url); lis
telem.append(listitem); } readinglis
telem.append(lis
telem); } } unregistering indexed content below is an asynchronous function, that removes an item from the content index.
CustomElementRegistry.whenDefined() - Web APIs
if the custom element is already defined, the promise is resolved immedia
tely.
... <menu-item>item n</menu-item> </nav-menu> </nav> const container = document.ge
telementbyid('menu-container'); const placeholder = container.queryselector('.menu-placeholder'); // fetch all the children of menu that are not yet defined.
DOMImplementation.createHTMLDocument() - Web APIs
here's the html for this example: <body> <p>click <a href="javascript:makedocument()">here</a> to create a new document and insert it below.</p> <iframe id="theframe" src="about:blank" /> </body> the javascript implementation of makedocument() follows: function makedocument() { let frame = document.ge
telementbyid("theframe"); let doc = document.implementation.createhtmldocument("new document"); let p = doc.createelement("p"); p.innerhtml = "this is a new paragraph."; try { doc.body.appendchild(p); } catch(e) { console.log(e); } // copy the new html document into the frame let destdocument = frame.contentdocument; let srcnode = doc.documen
telement; let newnode = des...
...tdocument.importnode(srcnode, true); destdocument.replacechild(newnode, destdocument.documen
telement); } the code in lines 4–12 handle creating the new html document and inserting some content into it.
DOMMatrixReadOnly - Web APIs
if no matrix is specified as the multiplier, the matrix is multiplied by a matrix in which every element is 0 except the bottom-right corner and the element immedia
tely above and to its left: m33 and m34.
...if no matrix is specified, the matrix is initialized with every element set to 0 except the bottom-right corner and the element immedia
tely above and to its left: m33 and m34.
DataTransfer.clearData() - Web APIs
status">drag to start</span></div> <div>data is: <span id="data">uninitialized</span></div> css span.tweaked { display: inline-block; margin: 1em 0; padding: 1em 2em; } #source { color: blue; border: 1px solid black; } #target { border: 1px solid black; } javascript window.addeventlistener('domcontentloaded', function () { // select html elements var draggable = document.ge
telementbyid('source'); var dropable = document.ge
telementbyid('target'); var status = document.ge
telementbyid('status'); var data = document.ge
telementbyid('data'); var dropped = false; // register event handlers draggable.addeventlistener('dragstart', dragstarthandler); draggable.addeventlistener('dragend', dragendhandler); dropable.addeventlistener('dragover', dragoverhandler); ...
...); } function dragleavehandler (event) { status.innerhtml = 'drag in process (drop was available)'; event.preventdefault(); } function drophandler (event) { dropped = true; status.innerhtml = 'drop done'; event.preventdefault(); // get data linked to event format « text » var _data = event.datatransfer.getdata('text/plain'); var element = document.ge
telementbyid(_data); // append drag source element to event's target element event.target.appendchild(element); // change css styles and displayed text element.style.csstext = 'border: 1px solid black;display: block; color: red'; element.innerhtml = "i'm in the drop zone!"; } }) specifications specification status comment html living standardthe de...
DeprecationReportBody - Web APIs
examples in our deprecation_report.html example, we create a simple reporting observer to observe usage of deprecated features on our web page: let options = { types: ['deprecation'], buffered: true } let observer = new reportingobserver(function(reports, observer) { reportbtn.onclick = () => displayreports(reports); }, options); we then
tell it to start observing reports using reportingobserver.observe(); this
tells the observer to start collecting reports in its report queue, and runs the callback function specified inside the constructor: observer.observe(); because of the event handler we set up inside the reportingobserver() constructor, we can now click the button to display the report details.
... the report details are displayed via the displayreports() fuction, which takes the observer callback's reports parameter as its parameter: function displayreports(reports) { const outpu
telem = document.queryselector('.output'); const list = document.createelement('ul'); outpu
telem.appendchild(list); for(let i = 0; i < reports.length; i++) { let listitem = document.createelement('li'); let textnode = document.createtextnode('report ' + (i + 1) + ', type: ' + reports[i].type); listitem.appendchild(textnode); let innerlist = document.createelement('ul'); listitem.appendchild(innerlist); list.appendchild(listitem); for (let key in reports[i].body) { let innerlistitem = document.createelement('li'); let keyvalue = reports[i].body[key]; i...
Document.onfullscreenchange - Web APIs
the document interface's onfullscreenchange property is an event handler for the fullscreenchange event that is fired immedia
tely before a document transitions into or out of full-screen mode.
... example document.onfullscreenchange = function ( event ) { console.log("full screen change") }; document.documen
telement.onclick = function () { // requestfullscreen() must be in an event handler or it will fail document.documen
telement.requestfullscreen(); } specifications specification status comment fullscreen apithe definition of 'onfullscreenchange' in that specification.
Document.write() - Web APIs
after writing, call document.close() to
tell the browser to finish loading the page.
...for example: <script> document.write("<h1>main title</h1>") </script> note: document.write() and document.wri
teln do not work in xhtml documents (you'll get an "operation is not supported" [ns_error_dom_not_supported_err] error in the error console).
DocumentOrShadowRoot.activeElement - Web APIs
often activeelement will return a htmlinpu
telement or htmltextareaelement object if it has the text selection at the time.
...morbi sed euismod diam.</textarea> </form> <p>active element id: <b id="output-element"></b></p> <p>selected text: <b id="output-text"></b></p> javascript function onmouseup(e) { const activetextarea = document.activeelement; const selection = activetextarea.value.substring( activetextarea.selectionstart, activetextarea.selectionend ); const outpu
telement = document.ge
telementbyid('output-element'); const outputtext = document.ge
telementbyid('output-text'); outpu
telement.innerhtml = activetextarea.id; outputtext.innerhtml = selection; } const textarea1 = document.ge
telementbyid('ta-example-one'); const textarea2 = document.ge
telementbyid('ta-example-two'); textarea1.addeventlistener('mouseup', onmouseup, false); textarea2.addeventliste...
Example - Web APIs
<html> <head> <title>my document</title> <script type="text/javascript"> function change() { // document.ge
telementsbytagname("h1") returns a nodelist of the h1 // elements in the document, and the first is number 0: var header = document.ge
telementsbytagname("h1").item(0); // the firstchild of the header is a text node: header.firstchild.data = "a dynamic document"; // now the header is "a dynamic document".
... var para = document.ge
telementsbytagname("p").item(0); para.firstchild.data = "this is the first paragraph."; // create a new text node for the second paragraph var newtext = document.createtextnode("this is the second paragraph."); // create a new element to be the second paragraph var newelement = document.createelement("p"); // put the text in the paragraph newelement.appendchild(newtext); // and put the paragraph on the end of the document by appending it to // the body (which is the parent of para) para.parentnode.appendchild(newelement); } </script> </head> <body> <input type="button" value="change this document." onclick="change()"> <h1>header</h1> <p>paragraph</p> </body> </head> ...
Using the W3C DOM Level 1 Core - Web APIs
the following script would do the job: html content <body> <input type="button" value="change this document." onclick="change()"> <h2>header</h2> <p>paragraph</p> </body> javascript content function change() { // document.ge
telementsbytagname("h2") returns a nodelist of the <h2> // elements in the document, and the first is number 0: var header = document.ge
telementsbytagname("h2").item(0); // the firstchild of the header is a text node: header.firstchild.data = "a dynamic document"; // now the header is "a dynamic document".
... var para = document.ge
telementsbytagname("p").item(0); para.firstchild.data = "this is the first paragraph."; // create a new text node for the second paragraph var newtext = document.createtextnode("this is the second paragraph."); // create a new element to be the second paragraph var newelement = document.createelement("p"); // put the text in the paragraph newelement.appendchild(newtext); // and put the paragraph on the end of the document by appending it to // the body (which is the parent of para) para.parentnode.appendchild(newelement); } you can see this script as a complete example.
Element.animate() - Web APIs
examples in the demo down the rabbit hole (with the web animation api), we use the convenient animate() method to immedia
tely create and play an animation on the #tunnel element to make it flow upwards, infini
tely.
... document.ge
telementbyid("tunnel").animate([ // keyframes { transform: 'translatey(0px)' }, { transform: 'translatey(-300px)' } ], { // timing options duration: 1000, iterations: infinity }); implicit to/from keyframes in newer browser versions, you are able to set a beginning or end state for an animation only (i.e.
Element.attributes - Web APIs
syntax var attr = element.attributes; example basic examples // get the first <p> element in the document var para = document.ge
telementsbytagname("p")[0]; var atts = para.attributes; enumerating elements attributes numerical indexing is useful for going through all of an element's attributes.
... <!doctype html> <html> <head> <title>attributes example</title> <script type="text/javascript"> function listattributes() { var paragraph = document.ge
telementbyid("paragraph"); var result = document.ge
telementbyid("result"); // first, let's verify that the paragraph has some attributes if (paragraph.hasattributes()) { var attrs = paragraph.attributes; var output = ""; for(var i = attrs.length - 1; i >= 0; i--) { output += attrs[i].name + "->" + attrs[i].value; } result.value = output; } else { result.value = "no attributes to show"; } } </script> </hea...
Element.classList - Web APIs
document.documen
telement.firstchild.appendchild(document.createelement('style')).stylesheet.csstext=( '_*{x-uclp:expression(!this.hasownproperty("classlist")&&window[" ucl"](this))}' + // ie6 '[class]{x-uclp/**/:expression(!this.hasownproperty("classlist")&&window[" ucl"](this))}' //ie7-8 ); } })(window); // 3.
...however, such actions would not work in ie6-ie8 and, in ie9, slow the performance of the entire webpage to a snail's crawl, making these modifications comple
tely impractical for this polyfill.
Element.getAttributeNS() - Web APIs
<svg xmlns="http://www.w3.org/2000/svg" xmlns:test="http://www.example.com/2014/test" width="40" height="40"> <circle id="target" cx="12" cy="12" r="10" stroke="#444" stroke-width="2" fill="none" test:foo="hello namespaced attribute!"/> <script type="text/javascript"> var ns = 'http://www.example.com/2014/test'; var circle = document.ge
telementbyid( 'target' ); console.log( 'attribute test:foo: "' + circle.getattributens( ns, 'foo' ) + '"' ); </script> </svg> in an html5 document the attribute has to be accessed with test:foo since namespaces are not supported.
... <!doctype html> <html> <body> <svg xmlns="http://www.w3.org/2000/svg" xmlns:test="http://www.example.com/2014/test" width="40" height="40"> <circle id="target" cx="12" cy="12" r="10" stroke="#444" stroke-width="2" fill="none" test:foo="foo value"/> </svg> <script type="text/javascript"> var ns = 'http://www.example.com/2014/test'; var circle = document.ge
telementbyid( 'target' ); console.log('attribute value: ' + circle.getattribute('test:foo')); </script> </body> </html> notes namespaces are only supported in xml documents.
Element.releasePointerCapture() - Web APIs
syntax targe
telement.releasepointercapture(pointerid); parameters pointerid the pointerid of a pointerevent object.
...lign-items: center; justify-content: center; background: #fbe; } javascript function beginsliding(e) { slider.onpointermove = slide; slider.setpointercapture(e.pointerid); } function stopsliding(e) { slider.onpointermove = null; slider.releasepointercapture(e.pointerid); } function slide(e) { slider.style.transform = `translate(${e.clientx - 70}px)`; } const slider = document.ge
telementbyid('slider'); slider.onpointerdown = beginsliding; slider.onpointerup = stopsliding; result specifications specification status comment pointer events – level 2the definition of 'releasepointercapture' in that specification.
Element.setCapture() - Web APIs
<html> <head> <title>mouse capture example</title> <style type="text/css"> #mybutton { border: solid black 1px; color: black; padding: 2px; box-shadow: black 2px 2px; } </style> <script type="text/javascript"> function init() { var btn = document.ge
telementbyid("mybutton"); if (btn.setcapture) { btn.addeventlistener("mousedown", mousedown, false); btn.addeventlistener("mouseup", mouseup, false); } else { document.ge
telementbyid("output").innerhtml = "sorry, there appears to be no setcapture support on this browser"; } } function mousedown(e) { e.target.setcapture(); e.targ...
...et.addeventlistener("mousemove", mousemoved, false); } function mouseup(e) { e.target.removeeventlistener("mousemove", mousemoved, false); } function mousemoved(e) { var output = document.ge
telementbyid("output"); output.innerhtml = "position: " + e.clientx + ", " + e.clienty; } </script> </head> <body onload="init()"> <p>this is an example of how to use mouse capture on elements in gecko 2.0.</p> <p><a id="mybutton" href="#">test me</a></p> <div id="output">no events yet</div> </body> </html> view live examples notes the element may not be scrolled comple
tely to the top or bottom, depending on the layout of other elements.
Element.setPointerCapture() - Web APIs
syntax targe
telement.setpointercapture(pointerid); parameters pointerid the pointerid of a pointerevent object.
...lign-items: center; justify-content: center; background: #fbe; } javascript function beginsliding(e) { slider.onpointermove = slide; slider.setpointercapture(e.pointerid); } function stopsliding(e) { slider.onpointermove = null; slider.releasepointercapture(e.pointerid); } function slide(e) { slider.style.transform = `translate(${e.clientx - 70}px)`; } const slider = document.ge
telementbyid('slider'); slider.onpointerdown = beginsliding; slider.onpointerup = stopsliding; result specifications specification status comment pointer events – level 2the definition of 'setpointercapture' in that specification.
ElementCSSInlineStyle.style - Web APIs
examples // set multiple styles in a single statement elt.style.csstext = "color: blue; border: 1px solid black"; // or elt.setattribute("style", "color:red; border: 1px solid blue;"); // set specific style while leaving other inline style values untouched elt.style.color = "blue"; getting style information the style property is not useful for comple
tely learning about the styles applied on the element, since it represents only the css declarations set in the element's inline style attribute, not those that come from style rules elsewhere, such as style rules in the <head> section, or external style sheets.
... the following code snippet demonstrates the difference between the values obtained using the element's style property and that obtained using the getcomputedstyle() method: <!doctype html> <html> <body style="font-weight:bold;"> <div style="color:red" id="myelement">..</div> </body> </html> var element = document.ge
telementbyid("myelement"); var out = ""; var elementstyle = element.style; var computedstyle = window.getcomputedstyle(element, null); for (prop in elementstyle) { if (elementstyle.hasownproperty(prop)) { out += " " + prop + " = '" + elementstyle[prop] + "' > '" + computedstyle[prop] + "'\n"; } } console.log(out) the output would be something like: ...
Comparison of Event Targets - Web APIs
</thead> <tr> <td id="target"></td> <td id="currenttarget"></td> <td id="relatedtarget"></td> <td id="explicitoriginaltarget"></td> <td id="originaltarget"></td> </tr> </table> <p>clicking on the text will show the difference between explicitoriginaltarget, originaltarget, and target</p> <script> function handleclicks(e) { document.ge
telementbyid('target').innerhtml = e.target; document.ge
telementbyid('currenttarget').innerhtml = e.currenttarget; document.ge
telementbyid('relatedtarget').innerhtml = e.relatedtarget; document.ge
telementbyid('explicitoriginaltarget').innerhtml = e.explicitoriginaltarget; document.ge
telementbyid('originaltarget').innerhtml = e.originaltarget; } function handle...
...mouseover(e) { document.ge
telementbyid('target').innerhtml = e.target; document.ge
telementbyid('relatedtarget').innerhtml = e.relatedtarget; } document.addeventlistener('click', handleclicks, false); document.addeventlistener('mouseover', handlemouseover, false); </script> </body> </html> use of target and relatedtarget the relatedtarget property for the mouseover event holds the node that the mouse was previously over.
EventTarget.removeEventListener() - Web APIs
if a listener is registered twice, one with capture and one without, remove each one separa
tely.
... const body = document.queryselector('body') const clicktarget = document.ge
telementbyid('click-target') const mouseovertarget = document.ge
telementbyid('mouse-over-target') let toggle = false; function makebackgroundyellow() { if (toggle) { body.style.backgroundcolor = 'white'; } else { body.style.backgroundcolor = 'yellow'; } toggle = !toggle; } clicktarget.addeventlistener('click', makebackgroundyellow, false ); mouseovertarget.
FileList - Web APIs
for example, if the html includes the following file input: <input id="fileitem" type="file"> the following line of code fetches the first file in the node's file list as a file object: var file = document.ge
telementbyid('fileitem').files[0]; method overview file item(index); properties attribute type description length integer a read-only value indicating the number of files in the list.
... example this example iterates over all the files selected by the user using an input element: // fileinput is an html input element: <input type="file" id="myfileinput" multiple> var fileinput = document.ge
telementbyid("myfileinput"); // files is a filelist object (similar to nodelist) var files = fileinput.files; var file; // loop through files for (var i = 0; i < files.length; i++) { // get item file = files.item(i); //or file = files[i]; alert(file.name); } here is a complete example.
FileSystemDirectoryEntry.removeRecursively() - Web APIs
androidopera for androidsafari on iossamsung internetremoverecursively deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immedia
tely called the error callback with ns_error_dom_security_err.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support ...
... 18firefox android no support 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immedia
tely called the error callback with ns_error_dom_security_err.opera android no support nosafari ios no support nosamsung internet android full support yeslegend full support full support no support no supportnon-standard.
FileSystemDirectoryEntry - Web APIs
full support yesremoverecursively deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immedia
tely called the error callback with ns_error_dom_security_err.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support ...
... 18firefox android no support 50 — 52notes no support 50 — 52notes notes while the removerecursively() method existed, it immedia
tely called the error callback with ns_error_dom_security_err.opera android no support nosafari ios no support nosamsung internet android full support yeslegend full support full support no support no supportexperimental.
FileSystemFileEntry.createWriter() - Web APIs
irefox for androidopera for androidsafari on iossamsung internetcreatewriter deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immedia
tely called errorcallback with the ns_error_dom_security_err error.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support ...
... 18firefox android no support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immedia
tely called errorcallback with the ns_error_dom_security_err error.opera android no support nosafari ios no support nosamsung internet android full support yeslegend full support full support no support no supportnon-standard.
FileSystemFileEntry - Web APIs
yesprefixed prefixed implemented with the vendor prefix: webkitcreatewriter deprecatednon-standardchrome full support 8edge full support 79firefox no support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immedia
tely called errorcallback with the ns_error_dom_security_err error.ie no support noopera no support nosafari no support nowebview android full support ≤37chrome android full support ...
... 18firefox android no support 50 — 52notes no support 50 — 52notes notes while the createwriter() method existed, it immedia
tely called errorcallback with the ns_error_dom_security_err error.opera android no support nosafari ios no support nosamsung internet android full support yesfilechrome full support 8edge full support 79firefox full support 50ie no support noopera no support ...
Using FormData Objects - Web APIs
creating a formdata object from scratch you can build a formdata object yourself, instantiating it then appending fields to it by calling its append() method, like this: var formdata = new formdata(); formdata.append("username", "groucho"); formdata.append("accountnum", 123456); // number 123456 is immedia
tely converted to a string "123456" // html file input, chosen by user formdata.append("userfile", fileinpu
telement.files[0]); // javascript file-like object var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file...
...the number assigned to the field "accountnum" is immedia
tely converted into a string by the formdata.append() method (the field's value can be a blob, file, or a string: if the value is neither a blob nor a file, the value is converted to a string).
FullscreenOptions.navigationUI - Web APIs
example in this example, the entire document is placed into full-screen mode by calling requestfullscreen() on the document's document.documen
telement, which is the document's root <html> element.
... let elem = document.documen
telement; elem.requestfullscreen({ navigationui: "show" }).then({}).catch(err => { alert(`an error occurred while trying to switch into full-screen mode: ${err.message} (${err.name})`); }); the promise's resolve handler does nothing, but if the promise is rejected, an error message is displayed by calling alert().
GlobalEventHandlers.onanimationcancel - Web APIs
function log(msg, event) { let logbox = document.ge
telementbyid("log"); logbox.innerhtml += msg; if (event) { logbox.innerhtml += " <code>"+ event.animationname + "</code> at time " + event.elapsedtime.tofixed(2) + " seconds."; } logbox.innerhtml += "\n"; }; then we set up the handlecancelevent() function, which is called in response to the animationcancel event, as set up in the html above.
... function handlecancelevent(event) { log("animation canceled", event); }; then we add a method to handle toggle display between "flex" and "none" and establish it as the handler for a click event on the "hide/show" the box button: document.ge
telementbyid('togglebox').addeventlistener('click', function() { if (box.style.display == "none") { box.style.display = "flex"; document.ge
telementbyid("togglebox").innerhtml = "hide the box"; } else { box.style.display = "none"; document.ge
telementbyid("togglebox").innerhtml = "show the box"; } }); toggling the box to display: none has the effect of aborting its animation.
GlobalEventHandlers.onanimationend - Web APIs
function log(msg, event) { let logbox = document.ge
telementbyid("log"); logbox.innerhtml += msg; if (event) { logbox.innerhtml += " <code>"+ event.animationname + "</code> at time " + event.elapsedtime.tofixed(2) + " seconds."; } logbox.innerhtml += "\n"; }; then we set up the event handlers for the animationstart and animationend events: let box = document.ge
telementbyid("box"); box.onanimationstart = function(even...
...t) { log("animation started", event); } box.onanimationend = function(event) { log("animation stopped", event); }; finally, we set up a handler for a click on the button that runs the animation: document.ge
telementbyid("play").addeventlistener("click", function(event) { document.ge
telementbyid("box").classname = "slideanimation"; event.target.style.display = "none"; }, false); this sets the class of the box we want to animate to the class that contains the animation description, then hides the play button because this example will only run the animation once.
GlobalEventHandlers.onanimationiteration - Web APIs
var box = document.ge
telementbyid("box"); var iterationcounter = 0; box.onanimationiteration = function(event) { box.style.animationplaystate = "paused"; document.ge
telementbyid("play").innerhtml = "start iteration #" + (iterationcounter+1); }; this sets up two global variables: box, which references the "box" element that we're animating, and iterationcounter, which is initially zero, which indicates how many ite...
... finally, we set up a handler for a click on the button that runs the animation: document.ge
telementbyid("play").addeventlistener("click", function(event) { box.style.animationplaystate = "running"; iterationcounter++; }, false); this sets the box element's animation-play-state to "running" and increments the iteration counter.
GlobalEventHandlers.onanimationstart - Web APIs
function log(msg, event) { let logbox = document.ge
telementbyid("log"); logbox.innerhtml += msg; if (event) { logbox.innerhtml += " <code>"+ event.animationname + "</code> at time " + event.elapsedtime.tofixed(2) + " seconds."; } logbox.innerhtml += "\n"; }; then we set up the event handlers for the animationstart and animationend events: let box = document.ge
telementbyid("box"); box.onanimationstart = function(even...
...t) { log("animation started", event); } box.onanimationend = function(event) { log("animation stopped", event); }; finally, we set up a handler for a click on the button that runs the animation: document.ge
telementbyid("play").addeventlistener("click", function(event) { document.ge
telementbyid("box").classname = "slideanimation"; event.target.style.display = "none"; }, false); this sets the class of the box we want to animate to the class that contains the animation description, then hides the play button because this example will only run the animation once.
GlobalEventHandlers.onclick - Web APIs
html <div id="demo">click here</div> javascript document.ge
telementbyid('demo').onclick = function changecontent() { document.ge
telementbyid('demo').innerhtml = "help me"; document.ge
telementbyid('demo').style = "color: red"; } result getting the coordinates of clicks this example displays the coordinates at which the most recent mouse button click occurred.
... html <p>click anywhere in this example.</p> <p id="log"></p> javascript let log = document.ge
telementbyid('log'); document.onclick = inputchange; function inputchange(e) { log.textcontent = `position: (${e.clientx}, ${e.clienty})`; } result specification specification status comment html living standardthe definition of 'onclick' in that specification.
GlobalEventHandlers.ondrag - Web APIs
syntax var draghandler = targe
telement.ondrag; return value draghandler the drag event handler for element targe
telement.
...; } </style> </head> <script> function drag_handler(ev) { console.log("drag"); } function dragstart_handler(ev) { console.log("dragstart"); ev.datatransfer.setdata("text", ev.target.id); } function drop_handler(ev) { console.log("drop"); ev.currenttarget.style.background = "lightyellow"; ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragover_handler(ev) { console.log("dragover"); ev.preventdefault(); } </script> <body> <h1>examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <div> <!-- <div class="source"> --> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> select this element...
GlobalEventHandlers.ondragover - Web APIs
syntax var dragoverhandler = targe
telement.ondragover; return value dragoverhandler the dragover event handler for element targe
telement.
...; } </style> </head> <script> function drag_handler(ev) { console.log("drag"); } function dragstart_handler(ev) { console.log("dragstart"); ev.datatransfer.setdata("text", ev.target.id); } function drop_handler(ev) { console.log("drop"); ev.currenttarget.style.background = "lightyellow"; ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragover_handler(ev) { console.log("dragover"); ev.preventdefault(); } </script> <body> <h1>examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <div> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> select this element, drag it to the drop zone and...
GlobalEventHandlers.ondragstart - Web APIs
syntax var dragstarthandler = targe
telement.ondragstart; return value dragstarthandler the dragstart event handler for element targe
telement.
...; } </style> </head> <script> function drag_handler(ev) { console.log("drag"); } function dragstart_handler(ev) { console.log("dragstart"); ev.datatransfer.setdata("text", ev.target.id); } function drop_handler(ev) { console.log("drop"); ev.currenttarget.style.background = "lightyellow"; ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragover_handler(ev) { console.log("dragover"); ev.preventdefault(); } </script> <body> <h1>examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <div> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> select this element, drag it to the drop zone and...
GlobalEventHandlers.ondrop - Web APIs
syntax var drophandler = targe
telement.ondrop; return value drophandler the drop event handler for element targe
telement.
...; } </style> </head> <script> function drag_handler(ev) { console.log("drag"); } function dragstart_handler(ev) { console.log("dragstart"); ev.datatransfer.setdata("text", ev.target.id); } function drop_handler(ev) { console.log("drop"); ev.currenttarget.style.background = "lightyellow"; ev.preventdefault(); var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragover_handler(ev) { console.log("dragover"); ev.preventdefault(); } </script> <body> <h1>examples of <code>ondrag</code>, <code>ondrop</code>, <code>ondragstart</code>, <code>ondragover</code></h1> <div class="source"> <p id="source" ondrag="drag_handler(event);" ondragstart="dragstart_handler(event);" draggable="true"> select this element, drag it to th...
GlobalEventHandlers.onpointercancel - Web APIs
syntax targe
telement.onpointercancel = cancelhandler; var cancelhandler = targe
telement.onpointercancel; value cancelhandler the pointercancel event handler for element targe
telement.
... <html> <script> function cancelhandler(ev) { // process the pointercancel event } function init() { var el = document.ge
telementbyid('target1'); el.onpointercancel = cancelhandler; } </script> <body onload="init();"> <div id="target1"> touch me ...
GlobalEventHandlers.onpointerenter - Web APIs
syntax targe
telement.onpointerenter = enterhandler; var enterhandler = targe
telement.onpointerenter; value enterhandler the pointerenter event handler for element targe
telement.
... <html> <script> function enterhandler(ev) { // process the pointerenter event } function init() { let el = document.ge
telementbyid('target1'); el.onpointerenter = enterhandler; } </script> <body onload="init();"> <div id="target1"> touch me ...
GlobalEventHandlers.onpointermove - Web APIs
syntax targe
telement.onpointermove = movehandler; var movehandler = targe
telement.onpointermove; value movehandler the pointermove event handler for element targe
telement.
... <html> <script> function movehandler(ev) { // process the pointermove event } function init() { let el=document.ge
telementbyid('target1'); el.onpointermove = movehandler; } </script> <body onload="init();"> <div id="target1"> touch me ...
GlobalEventHandlers.onpointerout - Web APIs
syntax targe
telement.onpointerout = outhandler; var outhandler = targe
telement.onpointerout; value outhandler the pointerout event handler for element targe
telement.
... <html> <script> function outhandler(ev) { // process the pointerout event } function init() { let el=document.ge
telementbyid('target1'); el.onpointerout = outhandler; } </script> <body onload="init();"> <div id="target1"> touch me ...
GlobalEventHandlers.onpointerover - Web APIs
syntax targe
telement.onpointerover = overhandler; var overhandler = targe
telement.onpointerover; value overhandler the pointerover event handler for element targe
telement.
... <html> <script> function overhandler(ev) { // process the pointerover event } function init() { let el = document.ge
telementbyid('target1'); el.onpointerover = overhandler; } </script> <body onload="init();"> <div id="target1"> touch me ...
GlobalEventHandlers.onpointerup - Web APIs
syntax targe
telement.onpointerup = uphandler; var uphandler = targe
telement.onpointerup; value uphandler the pointerup event handler for element targe
telement.
... <html> <script> function uphandler(ev) { // process the pointerup event } function init() { let el = document.ge
telementbyid('target1'); el.onpointerup = uphandler; } </script> <body onload="init();"> <div id="target1"> touch me ...
GlobalEventHandlers.ontouchend - Web APIs
syntax var endhandler = targe
telement.ontouchend; return value endhandler the touchend event handler for element targe
telement.
... <html> <script> function endtouch(ev) { // process the event } function init() { var el=document.ge
telementbyid("target1"); el.ontouchend = endtouch; } </script> <body onload="init();"> <div id="target1"> touch me ...
HTMLCanvasElement.toDataURL() - Web APIs
examples given this <canvas> element: <canvas id="canvas" width="5" height="5"></canvas> you can get a data-url of the canvas with the following lines: var canvas = document.ge
telementbyid('canvas'); var dataurl = canvas.todataurl(); console.log(dataurl); // "data:image/png;base64,ivborw0kggoaaaansuheugaaaauaaaafcayaaacnby // blaaaadeleqvqimwngobmaaabpaafei8araaaaaelftksuqmcc" setting image quality with jpegs var fullquality = canvas.todataurl('image/jpeg', 1.0); // data:image/jpeg;base64,/9j/4aaqskzjrgabaq...9oadambaairaxeapwd/ad/6ap/z" var mediumquality = canvas.todat...
...class="grayscale" src="mypicture.png" alt="description of my picture" /> javascript window.addeventlistener('load', removecolors); function showcolorimg() { this.style.display = 'none'; this.nextsibling.style.display = 'inline'; } function showgrayimg() { this.previoussibling.style.display = 'inline'; this.style.display = 'none'; } function removecolors() { var aimages = document.ge
telementsbyclassname('grayscale'), nimgslen = aimages.length, ocanvas = document.createelement('canvas'), octx = ocanvas.getcontext('2d'); for (var nwidth, nheight, oimgdata, ograyimg, npixel, apix, npixlen, nimgid = 0; nimgid < nimgslen; nimgid++) { ocolorimg = aimages[nimgid]; nwidth = ocolorimg.offsetwidth; nheight = ocolorimg.offsetheight; ocanvas.width = nwidt...
HTMLElement: beforeinput event - Web APIs
bubbles yes cancelable yes interface inputevent event handler property none sync / async sync composed yes default action update the dom element examples this example logs current value of the element immedia
tely before replacing that value with the new one applied to the <input> element.
... html <input placeholder="enter some text" name="name"/> <p id="values"></p> javascript const input = document.queryselector('input'); const log = document.ge
telementbyid('values'); input.addeventlistener('beforeinput', updatevalue); function updatevalue(e) { log.textcontent = e.target.value; } result specifications specification status ui eventsthe definition of 'beforeinput event' in that specification.
HTMLElement: change event - Web APIs
eam"> <option value="">select one …</option> <option value="chocolate">chocolate</option> <option value="sardine">sardine</option> <option value="vanilla">vanilla</option> </select> </label> <div class="result"></div> body { display: grid; grid-template-areas: "select result"; } select { grid-area: select; } .result { grid-area: result; } javascript const selec
telement = document.queryselector('.ice-cream'); selec
telement.addeventlistener('change', (event) => { const result = document.queryselector('.result'); result.textcontent = `you like ${event.target.value}`; }); result text input element for some elements, including <input type="text">, the change event doesn't fire until the control loses focus.
... html <input placeholder="enter some text" name="name"/> <p id="log"></p> javascript const input = document.queryselector('input'); const log = document.ge
telementbyid('log'); input.addeventlistener('change', updatevalue); function updatevalue(e) { log.textcontent = e.target.value; } result specifications specification status html living standardthe definition of 'change' in that specification.
HTMLElement.hidden - Web APIs
javascript document.ge
telementbyid("okbutton") .addeventlistener("click", function() { document.ge
telementbyid("welcome").hidden = true; document.ge
telementbyid("awesome").hidden = false; }, false); this code sets up a handler for the welcome panel's "ok" button that hides the welcome panel and makes the follow-up panel—with the curious name "awesome"—visible in its place.
... the welcome panel <div id="welcome" class="panel"> <h1>welcome to foobar.com!</h1> <p>by clicking "ok" you agree to be awesome every day!</p> <button class="button" id="okbutton">ok</button> </div> this html creates a panel (in a <div> block) that welcomes the user to a site and
tells them what they're agreeing to by clicking the ok button.
HTMLElement.offsetHeight - Web APIs
syntax var in
telemoffsetheight = element.offsetheight; in
telemoffsetheight is a variable storing an integer corresponding to the offsetheight pixel value of the element.
...these elements are typically contained within scrollable elements; consequently, these non-scrollable elements may be comple
tely or partly invisible, depending on the scrolltop setting of the scrollable container.
HTMLElement.offsetLeft - Web APIs
example var colortable = document.ge
telementbyid("t1"); var toleft = colortable.offsetleft; if (toleft > 5) { // large left offset: do something here } this example shows a 'long' sentence that wraps within a div with a blue border, and a red box that one might think should describe the boundaries of the span.
...</span> <span id="longspan">long span that wraps within this div.</span> </div> <div id="box" style="position: absolute; border-color: red; border-width: 1; border-style: solid; z-index: 10"> </div> <script type="text/javascript"> var box = document.ge
telementbyid("box"); var longspan = document.ge
telementbyid("longspan"); box.style.left = longspan.offsetleft + document.body.scrollleft + "px"; box.style.top = longspan.offsettop + document.body.scrolltop + "px"; box.style.width = longspan.offsetwidth + "px"; box.style.height = longspan.offsetheight + "px"; </script> specification specification status comment css object model (cssom) view modu...
HTMLFormElement.elements - Web APIs
<form id="my-form"> <input type="text" name="username"> <input type="text" name="full-name"> <input type="password" name="password"> </form> var inputs = document.ge
telementbyid("my-form").elements; var inputbyindex = inputs[0]; var inputbyname = inputs["username"]; accessing form controls this example gets the form's element list, then iterates over the list, looking for <input> elements of type "text" so that some form of processing can be performed on them.
... var inputs = document.ge
telementbyid("my-form").elements; // iterate over the form controls for (i = 0; i < inputs.length; i++) { if (inputs[i].nodename === "input" && inputs[i].type === "text") { // update text input inputs[i].value.tolocaleuppercase(); } } disabling form controls var inputs = document.ge
telementbyid("my-form").elements; // iterate over the form controls for (i = 0; i < inputs.length; i++) { // disable all form controls inputs[i].setattribute("disabled", ""); } specifications specification status comment html living standardthe definition of 'htmlformelement.elements' in that specification.
HTMLImageElement - Web APIs
htmlimageelement.loading a domstring providing a hint to the browser used to optimize loading the document by determining whether to load the image immedia
tely (eager) or on an as-needed basis (lazy).
... htmlimageelement.referrerpolicy a domstring that reflects the referrerpolicy html attribute, which
tells the user agent how to decide which referrer to use in order to fetch the image.
HTMLMediaElement.seekToNextFrame() - Web APIs
this method returns immedia
tely, returning a promise, whose fulfillment handler is called when the seek operation is complete.
...if the seek fails because the media is already at the last frame, a seeked event occurs, followed immedia
tely by an ended event.
HTMLElement.focus() - Web APIs
examples focus on a text field javascript focusmethod = function getfocus() { document.ge
telementbyid("mytextfield").focus(); } html <input type="text" id="mytextfield" value="text field."> <p></p> <button type="button" onclick="focusmethod()">click me to focus on the text field!</button> result focus on a button javascript focusmethod = function getfocus() { document.ge
telementbyid("mybutton").focus(); } html <button type="button" id="mybutton">click me!</button>...
... <p></p> <button type="button" onclick="focusmethod()">click me to focus on the button!</button> result focus with focusoption javascript focusscrollmethod = function getfocus() { document.ge
telementbyid("mybutton").focus({preventscroll:false}); } focusnoscrollmethod = function getfocuswithoutscrolling() { document.ge
telementbyid("mybutton").focus({preventscroll:true}); } html <button type="button" onclick="focusscrollmethod()">click me to focus on the button!</button> <button type="button" onclick="focusnoscrollmethod()">click me to focus on the button without scrolling!</button> <div id="container" style="height: 1000px; width: 1000px;"> <button type="button" id="mybutton" style="margin-top: 500px;">click me!</button> </div> result specification ...
HTMLTableRowElement.insertCell() - Web APIs
the cell does not need to be appended separa
tely with node.appendchild() as would be the case if document.createelement() had been used to create the new <td> element.
... html <table id="my-table"> <tr><td>row 1</td></tr> <tr><td>row 2</td></tr> <tr><td>row 3</td></tr> </table> javascript function addrow(tableid) { // get a reference to the table let tableref = document.ge
telementbyid(tableid); // insert a row at the end of the table let newrow = tableref.insertrow(-1); // insert a cell in the row at index 0 let newcell = newrow.insertcell(0); // append a text node to the cell let newtext = document.createtextnode('new bottom row'); newcell.appendchild(newtext); } // call addrow() with the table's id addrow('my-table'); result specifications ...
In depth: Microtasks and the JavaScript runtime environment - Web APIs
consider the javascript program below: let outpu
telem = document.ge
telementbyid("output"); let userlanguages = { "mike": "en", "teresa": "es" }; function greetuser(user) { function localgreeting(user) { let greeting; let language = userlanguages[user]; switch(language) { case "es": greeting = `¡hola, ${user}!`; break; case "en": default: greeting = `hello, ${user}!`; break; ...
... } return greeting; } outpu
telem.innerhtml += localgreeting(user) + "<br>\r"; } greetuser("mike"); greetuser("teresa"); greetuser("veronica"); this short program contains three execution contexts, some of which are created and destroyed several times over the course of the program's execution.
Dragging and Dropping Multiple Items - Web APIs
// [item1] data=url1, index=0 // [item2] data=url3, index=1 fortuna
tely, you don't normally need to clear items often; it's more common to just add the items only when you know they are needed.
... output(" item " + i + ":\n"); var types = dt.moztypesat(i); for (var t = 0; t < types.length; t++) { output(" " + types[t] + ": "); try { var data = dt.mozgetdataat(types[t], i); output("(" + (typeof data) + ") : <" + data + " >\n"); } catch (ex) { output("<<error>>\n"); dump(ex); } } } } function output(text) { document.ge
telementbyid("output").textcontent += text; dump(text); } </script> </head> <body> <div id="output" style="min-height: 100px; white-space: pre; border: 1px solid black;" ondragenter="document.ge
telementbyid('output').textcontent = ''; event.stoppropagation(); event.preventdefault();" ondragover="event.stoppropagation(); event.preventdefault();" ondrop="event.stoppropagation(); even...
IDBDatabase - Web APIs
methods inherits from: eventtarget idbdatabase.close() returns immedia
tely and closes the connection to a database in a separate thread.
... idbdatabase.transaction() immedia
tely returns a transaction object (idbtransaction) containing the idbtransaction.objectstore method, which you can use to access your object store.
Basic concepts - Web APIs
they also have readystate, result, and errorcode properties that
tell you the status of the request.
... out-of-line key a key that is stored separa
tely from the value being stored.
Checking when a deadline is due - Web APIs
if not, we drop a message into our developer notifications pane (see the bottom left of the app ui) to
tell the user what is going on, and exit out of the function.
...we want all the values to match before we show the user some kind of notification to
tell them their deadline is up.
IntersectionObserver.unobserve() - Web APIs
var observer = new intersectionobserver(callback); observer.observe(document.ge
telementbyid("elementtoobserve")); /* ...
... */ observer.unobserve(document.ge
telementbyid("elementtoobserve")); specifications specification status comment intersection observerthe definition of 'intersectionobserver.unobserve()' in that specification.
IntersectionObserver - Web APIs
intersectionobserver.observe()
tells the intersectionobserver a target element to observe.
... intersectionobserver.unobserve()
tells the intersectionobserver to stop observing a particular target element.
Timing element visibility with the Intersection Observer API - Web APIs
and the threshold is set to an array containing the values 0.0 and 0.75; this will cause our callback to execute whenever a targeted element becomes comple
tely obscured or first starts to become unobscured (intersection ratio 0.0) or passes through 75% visible in either direction (intersection ratio 0.75).
...the ad's background color is set to the value specified in the new ad's record, and elements' classes and contents are set appropria
tely as well.
KeyboardEvent.code - Web APIs
de values are for each one.</p> <div id="output"> </div> css #output { font-family: arial, helvetica, sans-serif; border: 1px solid black; } javascript window.addeventlistener("keydown", function(event) { let str = "keyboardevent: key='" + event.key + "' | code='" + event.code + "'"; let el = document.createelement("span"); el.innerhtml = str + "<br/>"; document.ge
telementbyid("output").appendchild(el); }, true); try it out to ensure that keystrokes go to the sample, click in the output box below before pressing keys.
... let shipsize = { width: 30, height: 30 }; let position = { x: 200, y: 200 }; let moverate = 9; let turnrate = 5; let angle = 0; let spaceship = document.ge
telementbyid("spaceship"); next comes the function updateposition().
KeyboardEvent.key - Web APIs
in sequence 1 & 3, the keyboardevent.key attribute is defined and is set appropria
tely to a value according to the rules defined ealier.
... id="console-log"></pre> </div> </div> css .fx { -webkit-display: flex; display: flex; margin-left: -20px; margin-right: -20px; } .fx > div { padding-left: 20px; padding-right: 20px; } .fx > div:first-child { width: 30%; } .flex { -webkit-flex: 1; flex: 1; } #test-target { display: block; width: 100%; margin-bottom: 10px; } javascript let textarea = document.ge
telementbyid('test-target'), consolelog = document.ge
telementbyid('console-log'), btnclearconsole = document.ge
telementbyid('btn-clear-console'); function logmessage(message) { document.ge
telementbyid("console-log").innerhtml += message + "<br>"; } textarea.addeventlistener('keydown', (e) => { if (!e.repeat) logmessage(`key "${e.key}" pressed [event: keydown]`); else logmessage(`key ...
KeyframeEffect.target - Web APIs
syntax var targe
telement = document.ge
telementbyid("elementtoanimate"); var keyframes = new keyframeeffect( targe
telement, keyframeblock, timingoptions ); // returns #elementtoanimate keyframes.target; // assigns keyframes a new target keyframes.target = newtarge
telement; value an element, csspseudoelement, or null.
... examples in the follow the white rabbit example, whiterabbit sets the target element to be animated: var whiterabbit = document.ge
telementbyid("rabbit"); var rabbitdownkeyframes = new keyframeeffect( whiterabbit, [ { transform: 'translatey(0%)' }, { transform: 'translatey(100%)' } ], { duration: 3000, fill: 'forwards' } ); // returns <div id="rabbit">click the rabbit's ears!</div> rabbitdownkeyframes.target; specifications specification status comment web animationsthe definition of 'keyframeeffect' in that specification.
MSCandidateWindowShow - Web APIs
mscandidatewindowshow fires immedia
tely after the input method editor (ime) candidate window is set to appear, but before it renders.
... example in ie11, developers can detect the opening of the ime candidate window by listening to mscandidatewindowshow event, then call getcandidatewindowclientrect() function to find out where the candidate window is and position the suggestion ui away from it: var context = document.ge
telementbyid("mysearchbox").msgetinputcontext(); context.addeventlistener("mscandidatewindowshow", candidatewindowshowhandler); function candidatewindowshowhandler(e) { var imerect = context.getcandidatewindowclientrect(); var suggestionrect = document.ge
telementbyid("mysuggestionlist").getboundingclientrect(); // check if the two rects intersect, and position them away from each other.
MediaDevices.ondevicechange - Web APIs
let videoelement = document.ge
telementbyid("video"); let logelement = document.ge
telementbyid("log"); function log(msg) { logelement.innerhtml += msg + "<br>"; } document.ge
telementbyid("startbutton").addeventlistener("click", function() { navigator.mediadevices.getusermedia({ video: { width: 160, height: 120, framerate: 30 }, audio: { samplerate: 44100, samplesize: 16, volume...
...: 0.25 } }).then(stream => { videoelement.srcobject = stream; updatedevicelist(); }) .catch(err => log(err.name + ": " + err.message)); }, false); we set up global variables that contain references to the <ul> elements that are used to list the audio and video devices: let audiolist = document.ge
telementbyid("audiolist"); let videolist = document.ge
telementbyid("videolist"); getting and drawing the device list now let's take a look at updatedevicelist() itself.
MediaElementAudioSourceNode - Web APIs
e.pagey : event.clienty + (document.documen
telement.scrolltop ?
... document.documen
telement.scrolltop : document.body.scrolltop); gainnode.gain.value = cury/height; } // connect the audiobuffersourcenode to the gainnode // and the gainnode to the destination, so we can play the // music and adjust the volume using the mouse cursor source.connect(gainnode); gainnode.connect(audioctx.destination); note: as a consequence of calling createmediaelementsource(), audio playback from the htmlmediaelement will be re-routed into the processing graph of the audiocontext.
MediaStreamTrack: mute event - Web APIs
musictrack.addeventlistener("mute", event => { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#aaa"; }, false); musictrack.addeventlistener("unmute", event => { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#fff"; }, false); with these event handlers in place, when the track musictrack enters its muted state, the element with the id timeline-widget gets its background color changed to #aaa.
...the following example shows this: musictrack.onmute = event => { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#aaa"; } musictrack.mute = event = > { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#fff"; } specifications specification status comment media capture and streamsthe definition of 'mute' in that specification.
MediaStreamTrack: unmute event - Web APIs
musictrack.addeventlistener("mute", event => { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#aaa"; }, false); musictrack.addeventlistener("unmute", event => { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#fff"; }, false); with these event handlers in place, when the track musictrack enters its muted state, the element with the id timeline-widget gets its background color changed to #aaa.
...the following example shows this: musictrack.onmute = event => { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#aaa"; } musictrack.mute = event = > { document.ge
telementbyid("timeline-widget").style.backgroundcolor = "#fff"; } specifications specification status comment media capture and streamsthe definition of 'unmute' in that specification.
Using the Media Capabilities API - Web APIs
on> <option>2500</option> <option>800</option> </select> </li> </ul> <p><input type="button" value="test this video configuration" id="tryit"></p> </form> <ul id="results"></ul> javascript let mc = { videoconfiguration : new object(), tryit: function () { mc.createconfiguration(); mc.testit(); }, createconfiguration: function () { var size = document.ge
telementbyid('size').value.split('x'); mc.videoconfiguration = { type: 'file', video: { contenttype: document.ge
telementbyid('codec').value, width: size[0], height: size[1], bitrate: document.ge
telementbyid('bitrate').value, framerate: document.ge
telementbyid('framerate').value, } } }, testit: function () { let content = ''; ...
...' is ' : ' is not ') + 'power efficient.'; var ul = document.ge
telementbyid("results") li.innerhtml = content; ul.appendchild(li); }).catch((error) => { var li = document.createelement('li'), ul = document.ge
telementbyid("results"); li.innertext = 'codec ' + mc.videoconfiguration.video.contenttype + ' threw an error: ' + error; ul.appendchild(li); }); } } document.ge
telementbyid('tryit').addeventlistener...
MutationObserver.takeRecords() - Web APIs
the most common use case for this is to immedia
tely fetch all pending mutation records immedia
tely prior to disconnecting the observer, so that any pending mutations can be processed when stopping down the observer.
...this is done immedia
tely prior to calling disconnect() to stop observing the dom.
Navigator.registerProtocolHandler() - Web APIs
for example, this api lets webmail sites open mailto: urls, or voip sites open
tel: urls.
... otherwise, the scheme must be one of the following: bitcoin geo im irc ircs magnet mailto mms news nntp openpgp4fpr sip sms smsto ssh
tel urn webcal wtai xmpp example if your site is burgers.example.com, you can register a protocol handler for it to handle web+burger: links, like so: navigator.registerprotocolhandler("web+burger", "https://burgers.example.com/?burger=%s", "burger handler"); this creates a handler that lets web+burger: links send the user...
Online and offline events - Web APIs
this property existed in older versions of firefox and internet explorer (the specification based itself off of these prior implementations), so you can begin using it immedia
tely.
... here's the javascript part: window.addeventlistener('load', function() { var status = document.ge
telementbyid("status"); var log = document.ge
telementbyid("log"); function updateonlinestatus(event) { var condition = navigator.online ?
Node.previousSibling - Web APIs
the node.previoussibling read-only property returns the node immedia
tely preceding the specified one in its parent's childnodes list, or null if the specified node is the first in that list.
... syntax previousnode = node.previoussibling; example <img id="b0"> <img id="b1"> <img id="b2"> console.log(document.ge
telementbyid("b1").previoussibling); // <img id="b0"> console.log(document.ge
telementbyid("b2").previoussibling.id); // "b1" notes gecko-based browsers insert text nodes into a document to represent whitespace in the source markup.
Node - Web APIs
node.paren
telementread only returns an element that is the parent of this node.
... sample usage the following example prints the textcontent properties of each <span> tag in a <div> element named "box": <div id="box"> <span>foo</span> <span>bar</span> <span>baz</span> </div> const box = document.ge
telementbyid("box") eachnode(box, function(node) { if (null != node.textcontent) { console.log(node.textcontent) } }) the above will result in the following strings printing to the user's console: "\n\t", "foo", "\n\t", "bar", "\n\t", "baz" note: whitespace forms part of a text node, meaning indentation and newlines form separate text between the element nodes.
NodeFilter.acceptNode() - Web APIs
the nodefilter.acceptnode() method returns an unsigned short that will be used to
tell if a given node must be accepted or not by the nodeiterator or treewalker iteration algorithm.
... example var nodeiterator = document.createnodeiterator( // node to use as root document.ge
telementbyid('someid'), // only consider nodes that are text nodes (nodetype 3) nodefilter.show_text, // object containing the function to use for the acceptnode method // of the nodefilter { acceptnode: function(node) { // logic to determine whether to accept, reject or skip node // in this case, only accept nodes that have content // other than whitespace if ( ...
NodeFilter - Web APIs
nodefilter.acceptnode() returns an unsigned short that will be used to
tell if a given node must be accepted or not by the nodeiterator or treewalker iteration algorithm.
... example const nodeiterator = document.createnodeiterator( // node to use as root document.ge
telementbyid('someid'), // only consider nodes that are text nodes (nodetype 3) nodefilter.show_text, // object containing the function to use for the acceptnode method // of the nodefilter { acceptnode: function(node) { // logic to determine whether to accept, reject or skip node // in this case, only accept nodes that have content // other than whitespace if ( ...
OffscreenCanvas - Web APIs
var one = document.ge
telementbyid("one").getcontext("bitmaprenderer"); var two = document.ge
telementbyid("two").getcontext("bitmaprenderer"); var offscreen = new offscreencanvas(256, 256); var gl = offscreen.getcontext('webgl'); // ...
... main.js (main thread code): var htmlcanvas = document.ge
telementbyid("canvas"); var offscreen = htmlcanvas.transfercontroltooffscreen(); var worker = new worker("offscreencanvas.js"); worker.postmessage({canvas: offscreen}, [offscreen]); offscreencanvas.js (worker code): onmessage = function(evt) { var canvas = evt.data.canvas; var gl = canvas.getcontext("webgl"); // ...
Path2D() - Web APIs
<canvas id="canvas"></canvas> const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let path1 = new path2d(); path1.rect(10, 10, 100,100); let path2 = new path2d(path1); path2.moveto(220, 60); path2.arc(170, 60, 50, 0, 2 * math.pi); ctx.stroke(path2); using svg paths this example creates a path2d path using svg path data.
... <canvas id="canvas"></canvas> const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let p = new path2d('m10 10 h 80 v 80 h -80 z'); ctx.fill(p); specification specification status comment html living standardthe definition of 'path2d()' in that specification.
PaymentAddress.phone - Web APIs
the read-only phone property of the paymentaddress interface returns a string containing the
telephone number of the recipient or contact person.
... syntax var paymentphone = paymentaddress.phone; value a domstring containing the
telephone number for the recipient of the shipment or of the responsible party for payment.
PaymentRequest.show() - Web APIs
instead of immedia
tely failing, you could choose to call retry() on the response object to ask the user agent to try to process the payment again; this should usually only be done after the user has made any needed corrections to the order.
...} document.ge
telementbyid("buybutton").onclick = requestpayment; specifications specification status comment payment request apithe definition of 'show(optional detailspromise)' in that specification.
PerformanceNavigationTiming.domComplete - Web APIs
the domcomplete read-only property returns a timestamp representing the time value equal to the time immedia
tely before the user agent sets the current document readiness of the current document to complete.
... syntax perfentry.domcomplete; return value a timestamp representing a time value equal to the time immedia
tely before the user agent sets the current document readiness of the current document to complete.
PerformanceNavigationTiming.domContentLoadedEventEnd - Web APIs
the domcontentloadedeventend read-only property returns a timestamp representing the time value equal to the time immedia
tely after the current document's domcontentloaded event completes.
... syntax perfentry.domcontentloadedeventend; return value a timestamp representing the time value equal to the time immedia
tely after the current document's domcontentloaded event completes.
PerformanceNavigationTiming.domContentLoadedEventStart - Web APIs
the domcontentloadedeventstart read-only property returns a timestamp representing the time value equal to the time immedia
tely before the user agent fires the domcontentloaded event at the current document.
... syntax perfentry.domcontentloadedeventstart; return value a timestamp representing the time value equal to the time immedia
tely before the user agent fires the domcontentloaded event at the current document.
PerformanceNavigationTiming.domInteractive - Web APIs
the dominteractive read-only property returns a timestamp representing the time value equal to the time immedia
tely before the user agent sets the current document readiness of the current document to interactive.
... syntax perfentry.dominteractive; return value a timestamp representing the time value equal to the time immedia
tely before the user agent sets the current document readiness of the current document to interactive.
PerformanceNavigationTiming.loadEventStart - Web APIs
the loadeventstart read-only property returns a timestamp representing the time value equal to the time immedia
tely before the load event of the current document is fired.
... syntax perfentry.loadeventstart; return value a timestamp representing a time value equal to the time immedia
tely before the load event of the current document is fired.
PerformanceNavigationTiming.unloadEventEnd - Web APIs
the unloadeventend read-only property returns a timestamp representing the time value equal to the time immedia
tely after the user agent finishes the unload event of the previous document.
... syntax perfentry.unloadeventend; return value a timestamp representing a time value equal to the time immedia
tely after the user agent finishes the unload event of the previous document.
PerformanceNavigationTiming.unloadEventStart - Web APIs
the unloadeventstart read-only property returns a timestamp representing the time value equal to the time immedia
tely before the user agent starts the unload event of the previous document.
... syntax perfentry.unloadeventstart; return value a timestamp representing the time value equal to the time immedia
tely before the user agent starts the unload event of the previous document.
PerformanceResourceTiming.connectStart - Web APIs
the connectstart read-only property returns the timestamp immedia
tely before the user agent starts establishing the connection to the server to retrieve the resource.
... syntax resource.connectstart; return value a domhighrestimestamp immedia
tely before the browser starts to establish the connection to the server to retrieve the resource.
PerformanceResourceTiming.domainLookupEnd - Web APIs
the domainlookupend read-only property returns the timestamp immedia
tely after the browser finishes the domain name lookup for the resource.
... syntax resource.domainlookupend; return value a domhighrestimestamp representing the time immedia
tely after the browser finishes the domain name lookup for the resource.
PerformanceResourceTiming.domainLookupStart - Web APIs
the domainlookupstart read-only property returns the timestamp immedia
tely before the browser starts the domain name lookup for the resource.
... syntax resource.domainlookupstart; return value a domhighrestimestamp immedia
tely before the browser starts the domain name lookup for the resource.
PerformanceResourceTiming.requestStart - Web APIs
the requeststart read-only property returns a timestamp of the time immedia
tely before the browser starts requesting the resource from the server, cache, or local resource.
... syntax resource.requeststart; return value a domhighrestimestamp representing the time immedia
tely before the browser starts requesting the resource from the server example in the following example, the value of the *start and *end properties of all "resource" type events are logged.
PerformanceResourceTiming.responseEnd - Web APIs
the responseend read-only property returns a timestamp immedia
tely after the browser receives the last byte of the resource or immedia
tely before the transport connection is closed, whichever comes first.
... syntax resource.responseend; return value a domhighrestimestamp immedia
tely after the browser receives the last byte of the resource or immedia
tely before the transport connection is closed, whichever comes first.
PerformanceResourceTiming.responseStart - Web APIs
the responsestart read-only property returns a timestamp immedia
tely after the browser receives the first byte of the response from the server, cache, or local resource.
... syntax resource.responsestart; return value a domhighrestimestamp immedia
tely after the browser receives the first byte of the response from the server.
PerformanceResourceTiming.secureConnectionStart - Web APIs
the secureconnectionstart read-only property returns a timestamp immedia
tely before the browser starts the handshake process to secure the current connection.
... syntax resource.secureconnectionstart; return value if the resource is fetched over a secure connection, a domhighrestimestamp immedia
tely before the browser starts the handshake process to secure the current connection.
Pointer Lock API - Web APIs
other examples include apps for viewing maps or sa
tellite imagery.
... var tracker = document.ge
telementbyid('tracker'); var animation; function updateposition(e) { x += e.movementx; y += e.movementy; if (x > canvas.width + radius) { x = -radius; } if (y > canvas.height + radius) { y = -radius; } if (x < -radius) { x = canvas.width + radius; } if (y < -radius) { y = canvas.height + radius; } tracker.textcontent = "x position: " + x + ", y position: " + y; ...
Multi-touch interaction - Web APIs
function set_handlers(name) { // install event handlers for the given element var el=document.ge
telementbyid(name); el.onpointerdown = pointerdown_handler; el.onpointermove = pointermove_handler; // use same handler for pointer{up,cancel,out,leave} events since // the semantics for these events - in this app - are the same.
...false : true; } function log(name, ev) { var o = document.ge
telementsbytagname('output')[0]; var s = name + ": pointerid = " + ev.pointerid + " ; pointertype = " + ev.pointertype + " ; isprimary = " + ev.isprimary; o.innerhtml += s + " "; } function clearlog(event) { var o = document.ge
telementsbytagname('output')[0]; o.innerhtml = ""; } ...
Pinch zoom gestures - Web APIs
function init() { // install event handlers for the pointer target var el=document.ge
telementbyid("target"); el.onpointerdown = pointerdown_handler; el.onpointermove = pointermove_handler; // use same handler for pointer{up,cancel,out,leave} events since // the semantics for these events - in this app - are the same.
...false : true; } function log(prefix, ev) { if (!logevents) return; var o = document.ge
telementsbytagname('output')[0]; var s = prefix + ": pointerid = " + ev.pointerid + " ; pointertype = " + ev.pointertype + " ; isprimary = " + ev.isprimary; o.innerhtml += s + " "; } function clearlog(event) { var o = document.ge
telementsbytagname('output')[0]; o.innerhtml = ""; } ...
ProgressEvent - Web APIs
in other words, it
tells if the progress is measurable or not.
... var progressbar = document.ge
telementbyid("p"), client = new xmlhttprequest() client.open("get", "magical-unicorns") client.onprogress = function(pe) { if(pe.lengthcomputable) { progressbar.max = pe.total progressbar.value = pe.loaded } } client.onloadend = function(pe) { progressbar.value = pe.loaded } client.send() specifications specification status comment xmlhttprequestthe definit...
RTCConfiguration.certificates - Web APIs
syntax let rtcconfiguration = { certificates: certifica
telist }; let rtcconfiguration.certificates = [ cert1...
...one obvious benefit to providing your own is identity key continuity—if you use the same certificate for subsequent calls, the remote peer can
tell you're the same caller.
RTCIceTransport: selectedcandidatepairchange event - Web APIs
let icetransport = pc.getsenders[0].transport.icetransport; let localprotoelem = document.ge
telementbyid("local-protocol"); let remoteprotoelem = document.ge
telementbyid("remote-protocol"); icetransport.addeventlistener("selectedcandidatepairchange", ev => { let pair = icetransport.getselectedcandidatepair(); localprotoelem.innertext = pair.local.protocol.touppercase(); remoteprotoelem.innertext = pair.remote.protocol.touppercase(); }, false) this can also be done by setting the ons...
... let icetransport = pc.getsenders[0].transport.icetransport; let localprotoelem = document.ge
telementbyid("local-protocol"); let remoteprotoelem = document.ge
telementbyid("remote-protocol"); icetransport.onselectedcandidatepairchange = ev => { let pair = icetransport.getselectedcandidatepair(); localprotoelem.innertext = pair.local.protocol.touppercase(); remoteprotoelem.innertext = pair.remote.protocol.touppercase(); } specifications specification status comment webrtc 1.0: real-time communication between browsersthe definition of 'selectedcandidatepairchange' in that specification.
RTCPeerConnection.removeTrack() - Web APIs
the rtcpeerconnection.removetrack() method
tells the local end of the connection to stop sending media from the specified track, without actually removing the corresponding rtcrtpsender from the list of senders as reported by rtcpeerconnection.getsenders().
... var pc, sender; navigator.getusermedia({video: true}, function(stream) { pc = new rtcpeerconnection(); var track = stream.getvideotracks()[0]; sender = pc.addtrack(track, stream); }); document.ge
telementbyid("closebutton").addeventlistener("click", function(event) { pc.removetrack(sender); pc.close(); }, false); specifications specification status comment webrtc 1.0: real-time communication between browsersthe definition of 'rtcpeerconnection.removetrack()' in that specification.
RTCRtpSender - Web APIs
you can also obtain access to an rtcdtmfsender which can be used to send dtmf codes (to simulate the user pressing buttons on a
telephone's dial pad) to the remote peer.
... properties rtcrtpsender.dtmf read only an rtcdtmfsender which can be used to send dtmf tones using
telephone-event payloads on the rtp session represented by the rtcrtpsender object.
Range.compareNode() - Web APIs
the node is comple
tely selected by the range.
... example range = document.createrange(); range.selectnode(document.ge
telementsbytagname("div").item(0)); returnvalue = range.comparenode(document.ge
telementsbytagname("p").item(0)); notes this method is obsolete; you should use the w3c dom range.compareboundarypoints() method.
Range.extractContents() - Web APIs
syntax documentfragment = range.extractcontents(); example basic example var range = document.createrange(); range.selectnode(document.ge
telementsbytagname("div").item(0)); var documentfragment = range.extractcontents(); document.body.appendchild(documentfragment); moving items between containers this example lets you move items between two containers.
... html <p id="list1">123456</p> <button id="swap">swap selected item(s)</button> <p id="list2">abcdef</p> css body { pointer-events: none; } p { border: 1px solid; font-size: 2em; padding: .3em; } button { font-size: 1.2em; padding: .5em; pointer-events: auto; } javascript const list1 = document.ge
telementbyid('list1'); const list2 = document.ge
telementbyid('list2'); const button = document.ge
telementbyid('swap'); button.addeventlistener('click', e => { selection = window.getselection(); for (let i = 0; i < selection.rangecount; i++) { const range = selection.getrangeat(i); if (range.commonancestorcontainer === list1 || range.commonancestorcontainer.parentnode === list1)...
Range.selectNodeContents() - Web APIs
example range = document.createrange(); referencenode = document.ge
telementsbytagname("div")[0]; range.selectnodecontents(referencenode); live sample this example lets the user select and deselect a paragraph with buttons.
... html <p id="p"><b>use the buttons below</b> to select or deselect the contents of this paragraph.</p> <button id="select-button">select paragraph</button> <button id="deselect-button">deselect paragraph</button> javascript const p = document.ge
telementbyid('p'); const selectbutton = document.ge
telementbyid('select-button'); const deselectbutton = document.ge
telementbyid('deselect-button'); selectbutton.addeventlistener('click', e => { // clear any current selection const selection = window.getselection(); selection.removeallranges(); // select paragraph const range = document.createrange(); range.selectnodecontents(p); sele...
Range.setStart() - Web APIs
main st.<br> dodge city, ks<br> 67801<br> usa</p> <hr> <p>nodes in the original address:</p> <ol id="log"></ol> javascript const address = document.ge
telementbyid('address'); const log = document.ge
telementbyid('log'); // log info address.childnodes.foreach(node => { const li = document.createelement('li'); li.textcontent = `${node.nodename}, ${node.nodevalue}`; log.appendchild(li); }); // highlight the street and city const startoffset = 2; // start at third node: 101 e.
... html <p id="content">0123456789</p> <p id="log"></p> javascript const element = document.ge
telementbyid('content'); const textnode = element.childnodes[0]; const range = document.createrange(); range.setstart(textnode, 0); // start at first character range.setend(textnode, 5); // end at fifth character document.ge
telementbyid('log').textcontent = range; result specifications specification status comment domthe definition of 'range.setstart()' in that specif...
ReadableStream.ReadableStream() - Web APIs
underlyingsource can contain the following: start(controller) this is a method, called immedia
tely when the object is constructed.
... note: you could define your own custom queuingstrategy, or use an instance of by
telengthqueuingstrategy or countqueuingstrategy for this object value.
ReadableStream.cancel() - Web APIs
cancel is used when you've comple
tely finished with the stream and don't need any more data from it, even if there are chunks enqueued waiting to be read.
...to read those chunks still and not comple
tely get rid of the stream, you'd use readablestreamdefaultcontroller.close().
ReadableStreamDefaultReader.cancel() - Web APIs
cancel is used when you've comple
tely finished with the stream and don't need any more data from it, even if there are chunks enqueued waiting to be read.
...to read those chunks still and not comple
tely get rid of the stream, you'd use readablestreamdefaultcontroller.close().
RelativeOrientationSensor - Web APIs
examples basic example the following example, which is loosely based on in
tel's orientation phone demo, instantiates an relativeorientationsensor with a frequency of 60 times a second.
... note that the in
tel demo this is based on uses the absoluteoreintationsensor.
Report - Web APIs
examples in our deprecation_report.html example, we create a simple reporting observer to observe usage of deprecated features on our web page: let options = { types: ['deprecation'], buffered: true } let observer = new reportingobserver(function(reports, observer) { reportbtn.onclick = () => displayreports(reports); }, options); we then
tell it to start observing reports using reportingobserver.observe(); this
tells the observer to start collecting reports in its report queue, and runs the callback function specified inside the constructor: observer.observe(); because of the event handler we set up inside the reportingobserver() constructor, we can now click the button to display the report details.
... the report details are displayed via the displayreports() fuction, which takes the observer callback's reports parameter as its parameter: function displayreports(reports) { const outpu
telem = document.queryselector('.output'); const list = document.createelement('ul'); outpu
telem.appendchild(list); for(let i = 0; i < reports.length; i++) { let listitem = document.createelement('li'); let textnode = document.createtextnode('report ' + (i + 1) + ', type: ' + reports[i].type); listitem.appendchild(textnode); let innerlist = document.createelement('ul'); listitem.appendchild(innerlist); list.appendchild(listitem); for (let key in reports[i].body) { let innerlistitem = document.createelement('li'); let keyvalue = reports[i].body[key]; i...
Resource Timing API - Web APIs
the first property in the processing model is starttime which returns the timestamp immedia
tely before the resource loading process begins.
...the next stages are connectstart and connectend which are the timestamps immedia
tely before and after connecting to the server, respectively.
Response.redirected - Web APIs
fetch("awesome-picture.jpg").then(function(response) { let elem = document.ge
telementbyid("warning-message-box"); if (response.redirected) { elem.innerhtml = "unexpected redirect"; } else { elem.innerhtml = ""; } return response.blob(); }).then(function(imageblob) { let imgobjecturl = url.createobjecturl(imageblob); document.ge
telementbyid("img-element-id").src = imgobjecturl; }); disallowing redirects because using redirected to manually filter out red...
...irects can allow forgery of redirects, you should instead set the redirect mode to "error" in the init parameter when calling fetch(), like this: fetch("awesome-picture.jpg", { redirect: "error" }).then(function(response) { return response.blob(); }).then(function(imageblob) { let imgobjecturl = url.createobjecturl(imageblob); document.ge
telementbyid("img-element-id").src = imgobjecturl; }); specifications specification status comment fetchthe definition of 'redirected' in that specification.
SVGAnimationElement - Web APIs
the svganimationelement interface is the base interface for all of the animation element interfaces: svganimateelement, svgse
telement, svganimatecolorelement, svganimatemotionelement and svganimatetransformelement.
... svganimationelement.targe
telement read only an svgelement representing the element which is being animated.
SVGDocument - Web APIs
interface overview also implement none methods none properties domstring domain domstring referrer svgsvgelement roo
telement domstring title domstring url normative document svg 1.1 (2nd edition) properties name type description domain domstring the domain name of the se...
... roo
telement svgsvgelement the root "svg" in the document hierarchy.
SVGElement - Web APIs
svgelement.viewpor
telementread only the svgelement, which established the current viewport.
... abort fired when page loading is stopped before an svg element has been allowed to load comple
tely.
SVGSVGElement - Web APIs
svgsvgelement.forceredraw() in rendering environments supporting interactivity, forces the user agent to immedia
tely redraw all regions of the viewport that require updating.
... svgsvgelement.ge
telementbyid() searches this svg document fragment (i.e., the search is restricted to a subset of the document tree) for an element whose id is given by elementid.
SVGTransformList - Web APIs
any changes made to the item are immedia
tely reflected in the list.
...any changes made to the item are immedia
tely reflected in the list.
Using the Screen Capture API - Web APIs
a logical display surface is one which is in part or comple
tely obscured, either by being overlapped by another object to some extent, or by being entirely hidden or offscreen.
... const videoelem = document.ge
telementbyid("video"); const logelem = document.ge
telementbyid("log"); const star
telem = document.ge
telementbyid("start"); const stopelem = document.ge
telementbyid("stop"); // options for getdisplaymedia() var displaymediaoptions = { video: { cursor: "always" }, audio: false }; // set event listeners for the start and stop buttons star
telem.addeventlistener("click", function(evt) { sta...
ServiceWorkerGlobalScope.skipWaiting() - Web APIs
use this method with clients.claim() to ensure that updates to the underlying service worker take effect immedia
tely for both the current client and all other active clients.
... syntax serviceworkerglobalscope.skipwaiting().then(function() { //do something }); returns a promise that immedia
tely resolves with undefined.
ServiceWorkerRegistration.showNotification() - Web APIs
if this value is absent or false, the desktop version of chrome will auto-minimize notifications after approxima
tely twenty seconds.
...for example, this could be in the past when a notification is used for a message that couldn’t immedia
tely be delivered because the device was offline, or in the future for a meeting that is about to start.
Service Worker API - Web APIs
download, install and activate at this point, your service worker will observe the following lifecycle: download install activate the service worker is immedia
tely downloaded when a user first accesses a service worker–controlled site/page.
... reacting to push messages: start up a service worker to send users a message to
tell them new content is available.
Slottable: assignedSlot - Web APIs
the assignedslot read-only property of the slottable interface returns an htmlslo
telement representing the <slot> element the node is inserted in.
... syntax var slo
telement = elementinstance.assignedslot value an htmlslo
telement instance, or null if the element is not assigned to a slot, or if the associated shadow root was attached with its mode set to closed (see element.attachshadow for further details).
SpeechSynthesis.cancel() - Web APIs
if an utterance is currently being spoken, speaking will stop immedia
tely.
...this is quite a long sentence to say.'); var utterance2 = new speechsynthesisutterance('we should say another sentence too, just to be on the safe side.'); synth.speak(utterance1); synth.speak(utterance2); synth.cancel(); // utterance1 stops being spoken immedia
tely, and both are removed from the queue specifications specification status comment web speech apithe definition of 'cancel()' in that specification.
Storage - Web APIs
if(!localstorage.getitem('bgcolor')) { populatestorage(); } setstyles(); function populatestorage() { localstorage.setitem('bgcolor', document.ge
telementbyid('bgcolor').value); localstorage.setitem('font', document.ge
telementbyid('font').value); localstorage.setitem('image', document.ge
telementbyid('image').value); } function setstyles() { var currentcolor = localstorage.getitem('bgcolor'); var currentfont = localstorage.getitem('font'); var currentimage = localstorage.getitem('image'); document.ge
telementbyid('bgcolor').value =...
... currentcolor; document.ge
telementbyid('font').value = currentfont; document.ge
telementbyid('image').value = currentimage; htmlelem.style.backgroundcolor = '#' + currentcolor; pelem.style.fontfamily = currentfont; imgelem.setattribute('src', currentimage); } note: to see this running as a complete working example, see our web storage demo.
SubtleCrypto.deriveBits() - Web APIs
}, privatekey, 128 ); const buffer = new uint8array(sharedsecret, 0, 5); const sharedsecretvalue = document.queryselector(".ecdh .derived-bits-value"); sharedsecretvalue.classlist.add("fade-in"); sharedsecretvalue.addeventlistener("animationend", () => { sharedsecretvalue.classlist.remove("fade-in"); }); sharedsecretvalue.textcontent = `${buffer}...[${sharedsecret.by
telength} bytes total]`; } // generate 2 ecdh key pairs: one for alice and one for bob // in more normal usage, they would generate their key pairs // separa
tely and exchange public keys securely const generatealiceskeypair = window.crypto.subtle.generatekey( { name: "ecdh", namedcurve: "p-384" }, false, ["derivebits"] ); const generatebobskeypair = window.crypto.subtle.generatekey(...
...56" }, keymaterial, 256 ); const buffer = new uint8array(derivedbits, 0, 5); const derivedbitsvalue = document.queryselector(".pbkdf2 .derived-bits-value"); derivedbitsvalue.classlist.add("fade-in"); derivedbitsvalue.addeventlistener("animationend", () => { derivedbitsvalue.classlist.remove("fade-in"); }); derivedbitsvalue.textcontent = `${buffer}...[${derivedbits.by
telength} bytes total]`; } const derivebitsbutton = document.queryselector(".pbkdf2 .derive-bits-button"); derivebitsbutton.addeventlistener("click", () => { getderivedbits(); }); specifications specification status comment web cryptography apithe definition of 'subtlecrypto.derivebits()' in that specification.
Text - Web APIs
text.assignedslot read only returns the htmlslo
telement object associated with the element.
... slotable.assignedslot read only returns a htmlslo
telement representing the <slot> the node is inserted in.
TextMetrics - Web APIs
html <canvas id="canvas" width="550" height="500"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const baselinesabovealphabetic = ['fontboundingboxascent', 'actualboundingboxascent', 'emheightascent', 'hangingbaseline']; const baselinesbelowalphabetic = ['ideographicbaseline', 'emheightdescent', 'actualboundingboxdescent', 'fontboundingboxdescent']; const baselines = [...baselinesabovealphabetic, ...
... it can therefore be useful to use the sum of actualboundingboxleft and actualboundingboxright as a more accurate way to get the absolute text width: const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const text = 'abcdefghijklmnop'; ctx.font = 'italic 50px serif'; const textmetrics = ctx.measuretext(text); console.log(textmetrics.width); // 459.8833312988281 console.log(math.abs(textmetrics.actualboundingboxleft) + math.abs(textmetrics.actualboundingboxright)); // 462.8833333333333 specifications specification ...
Using the User Timing API - Web APIs
[" + i + "] = " + entries[i].name, 0); } // display each mark using getentriesname(); must look for each mark separa
tely entries = performance.getentriesbyname("mark-1","mark"); for (var i=0; i < entries.length; i++) { if (i == 0) log("= getentriesbyname('mark-1', 'mark')", 0); log("...
...[" + i + "] = " + entries[i].name, 1); } // display each measure using getentriesname() - have to look for each measure separa
tely entries = performance.getentriesbyname("measure-1","measure"); for (var i=0; i < entries.length; i++) { if (i == 0) log("= getentriesbyname('measure-1', 'measure')", 1); log("...
ValidityState.patternMismatch - Web APIs
if the field supports the pattern attribute -- which means the <input> is of type text,
tel, email, url, password, or search -- and the pattern value is set to a valid regular expression, if the value don't doesn't conform to the constraints set by the pattern value, the patternmismatch property will be true.
... examples given the following: <p> <label>enter your phone number in the format (123)456-7890 (<input name="
tel1" type="
tel" pattern="[0-9]{3}" placeholder="###" aria-label="3-digit area code" size="2"/>)- <input name="
tel2" type="
tel" pattern="[0-9]{3}" placeholder="###" aria-label="3-digit prefix" size="2"/> - <input name="
tel3" type="
tel" pattern="[0-9]{4}" placeholder="####" aria-label="4-digit number" size="3"/> </label> </p> here we have 3 sections for a north american phone number with an implicit label encompassing all three components of the phone number, expecting 3-digits, 3-digits and 4-digits respectively, as defined by the pattern attribute set on each.
ValidityState - Web APIs
toolong read only a boolean that is true if the value exceeds the specified maxlength for htmlinpu
telement or htmltextareaelement objects, or false if its length is less than or equal to the maximum length.
... tooshort read only a boolean that is true if the value fails to meet the specified minlength for htmlinpu
telement or htmltextareaelement objects, or false if its length is greater than or equal to the minimum length.
WEBGL_compressed_texture_astc - Web APIs
availability: astc compression is typically available on mali arm gpus, in
tel gpus, and nividia tegra chips.
... constants blocks bits per pixel arraybuffer by
telength bytes if height and width are 512 ext.compressed_rgba_astc_4x4_khr ext.compressed_srgb8_alpha8_astc_4x4_khr 4x4 8.00 floor((width + 3) / 4) * floor((height + 3) / 4) * 16 262144 ext.compressed_rgba_astc_5x4_khr ext.compressed_srgb8_alpha8_astc_5x4_khr 5x4 6.40 floor((width + 4) / 5) * floor((height + 3) / 4) * 16 210944 ext.compr...
WebGL2RenderingContext - Web APIs
to get an object of this interface, call getcontext() on a <canvas> element, supplying "webgl2" as the argument: var canvas = document.ge
telementbyid('mycanvas'); var gl = canvas.getcontext('webgl2'); webgl 2 is an extension to webgl 1.
... webgl2renderingcontext.waitsync() returns immedia
tely, but waits on the gl server until the given webglsync object is signaled.
WebGLProgram - Web APIs
examples using the program the steps to actually do some work with the program involve
telling the gpu to use the program, bind the appropriate data and configuration options, and finally draw something to the screen.
... // use the program gl.useprogram(program); // bind existing attribute data gl.bindbuffer(gl.array_buffer, buffer); gl.enablevertexattribarray(attribu
telocation); gl.vertexattribpointer(attribu
telocation, 3, gl.float, false, 0, 0); // draw a single triangle gl.drawarrays(gl.triangles, 0, 3); deleting the program if there is an error linking the program or you wish to delete an existing program, then it is as simple as running webglrenderingcontext.deleteprogram().
Creating 3D objects using WebGL - Web APIs
//
tell webgl how to pull out the positions from the position // buffer into the vertexposition attribute { const numcomponents = 3; ...
... drawing the cube next we need to add code to our drawscene() function to draw using the cube's index buffer, adding new gl.bindbuffer() and gl.drawelements() calls: //
tell webgl which indices to use to index the vertices gl.bindbuffer(gl.element_array_buffer, buffers.indices); ...
Lighting in WebGL - Web APIs
fortuna
tely, it's not all that hard to do, and this article will cover some of the basics.
... then we add the code to drawscene() to bind the normals array to a shader attribute so the shader code can get access to it: //
tell webgl how to pull out the normals from // the normal buffer into the vertexnormal attribute.
Using WebRTC data channels - Web APIs
the rtcdatachannel object is returned immedia
tely by createdatachannel(); you can
tell when the connection has been made successfully by watching for the open event to be sent to the rtcdatachannel.
...this makes it easy to write efficient routines that make sure there's always data ready to send without over-using memory or swamping the channel comple
tely.
Using bounded reference spaces - Web APIs
each vertex in the array has a y coordinate of 0 since the entire boundary is defined at floor level, extending upward to the ceiling or indefini
tely.
... keep in mind that by default, the viewer's position is placed immedia
tely above the floor, like a camera lying on the ground.
Spaces and reference spaces: Spatial tracking in WebXR - Web APIs
if your app provides a way for the user to move through the virtual world without physically moving in the real world (a so-called
teleportation mechanic), you can simply accept the new position and continue, allowing the jump from your previously-assumed position to be immedia
tely corrected with the new position.
...instead, use the difference between the current position and the new tracking position to compute the new
teleportation offset; that is, a transform applied to everything to adapt the position and orientation data from webxr to your needs.
Starting up and shutting down a WebXR session - Web APIs
be aware, however, that the emulator does not yet comple
tely emulate all of the webxr api, so you may run into problems you're not expecting.
... const immersiveok = await navigator.xr.issessionsupported("immersive-vr"); if (immersiveok) { // create and use an immersive vr session } else { // create an inline session instead, or
tell the user about the // incompatibility if inline is required } creating and starting the session a webxr session is represented by an xrsession object.
Web Authentication API - Web APIs
note that it is absolu
tely critical that the challenge be a buffer of random information (at least 16 bytes) and it must be generated on the server in order to ensure the security of the registration process.
...note that it is absolu
tely critical that the challenge be a buffer of random information (at least 16 bytes) and it must be generated on the server in order to ensure the security of the authentication process.
Web Locks API - Web APIs
the lock is automatically released when the callback returns, so usually the callback is an async function, which causes the lock to be released only when the async function has comple
tely finished.
... ifavailable: if specified, the lock request will fail if the lock cannot be granted immedia
tely without waiting.
Using the Web Speech API - Web APIs
this can sometimes be useful, say if a result is not comple
tely clear and you want to display a list if alternatives for the user to choose the correct one from.
...we use the htmlselec
telement selectedoptions property to return the currently selected <option> element.
Window.devicePixelRatio - Web APIs
in simpler terms, this
tells the browser how many of the screen's actual pixels should be used to draw a single css pixel.
... html <canvas id="canvas"></canvas> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); // set display size (css pixels).
Window.getDefaultComputedStyle() - Web APIs
example simple example var elem1 = document.ge
telementbyid("elemid"); var style = window.getdefaultcomputedstyle(elem1); longer example <style> #elem-container { position: absolute; left: 100px; top: 200px; height: 100px; } </style> <div id="elem-container">dummy</div> <div id="output"></div> <script> var elem = document.ge
telementbyid("elem-container"); var thecssprop = window.getdefaultcomputedstyle(elem).position; ...
... document.ge
telementbyid("output").innerhtml = thecssprop; // will output "static" </script> use with pseudo-elements the getdefaultcomputedstyle() method can pull style info from pseudo-elements (e.g., ::before or ::after).
window.postMessage() - Web APIs
this mechanism provides control over where messages are sent; for example, if postmessage() was used to transmit a password, it would be absolu
tely critical that this argument be a uri whose origin is the same as the intended receiver of the message containing the password, to prevent interception of the password by a malicious third party.
...this is a comple
tely foolproof way to avoid security problems.
Window.requestAnimationFrame() - Web APIs
the window.requestanimationframe() method
tells the browser that you wish to perform an animation and requests that the browser calls a specified function to update an animation before the next repaint.
... const element = document.ge
telementbyid('some-element-you-want-to-animate'); let start; function step(timestamp) { if (start === undefined) start = timestamp; const elapsed = timestamp - start; // `math.min()` is used here to make sure that the element stops at exactly 200px.
Window.scrollX - Web APIs
window.pagexoffset : (document.documen
telement || document.body.parentnode || document.body).scrollleft; var y = (window.pageyoffset !== undefined) ?
... window.pageyoffset : (document.documen
telement || document.body.parentnode || document.body).scrolltop; specification specification status comment css object model (cssom) view modulethe definition of 'window.scrollx' in that specification.
Window.scrollY - Web APIs
document.documen
telement.scrollleft : document.body.scrollleft; var y = supportpageoffset ?
...document.documen
telement.scrolltop : document.body.scrolltop; specification specification status comment css object model (cssom) view modulethe definition of 'window.scrolly' in that specification.
Window - Web APIs
window.requestanimationframe()
tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame.
... domcontentloaded fired when the document has been comple
tely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.
self.createImageBitmap() - Web APIs
a sprite sheet is an image containing multiple smaller images, each of which you want to be able to render separa
tely.
... var canvas = document.ge
telementbyid('mycanvas'), ctx = canvas.getcontext('2d'), image = new image(); // wait for the sprite sheet to load image.onload = function() { promise.all([ // cut out two sprites from the sprite sheet createimagebitmap(image, 0, 0, 32, 32), createimagebitmap(image, 32, 0, 32, 32) ]).then(function(sprites) { // draw each sprite onto the canvas ctx.drawimage(sprites[0], 0, 0); ctx.drawimage(sprites[1], 32, 32); }); } // load the sprite sheet from an image file image.src = 'sprites.png'; specifications specification status comment html living standardthe definition of 'createimagebitmap' in that specification.
Worker.terminate() - Web APIs
the terminate() method of the worker interface immedia
tely terminates the worker.
... example the following code snippet shows creation of a worker object using the worker() constructor, which is then immedia
tely terminated.
WorkerGlobalScope.navigator - Web APIs
ou call the following console.log(navigator); inside a worker (which would basically be the equivalent of self.console.log(self.navigator);, as these are being called on the worker scope, which can be referenced with workerglobalscope.self), you will get a workernavigator object written to the console — something like the following: object {online: true, useragent: "mozilla/5.0 (macintosh; in
tel mac os x 10_10_1) ap…ml, like gecko) chrome/40.0.2214.93 safari/537.36", product: "gecko", platform: "macin
tel", appversion: "5.0 (macintosh; in
tel mac os x 10_10_1) applewebki…ml, like gecko) chrome/40.0.2214.93 safari/537.36"…} appcodename: "mozilla" appname: "netscape" appversion: "5.0 (macintosh; in
tel mac os x 10_10_1) applewebkit/537.36 (khtml, like gecko) chrome/40.0.2214...
....93 safari/537.36" hardwareconcurrency: 4 online: true platform: "macin
tel" product: "gecko" useragent: "mozilla/5.0 (macintosh; in
tel mac os x 10_10_1) applewebkit/537.36 (khtml, like gecko) chrome/40.0.2214.93 safari/537.36" __proto__: object you could use this navigator object to return more information about the runtime envinronment, as you might do with a normal navigator object.
WritableStream - Web APIs
methods writablestream.abort() aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immedia
tely moved to an error state, with any queued writes discarded.
... the promise returned by the sink's write() method (line 40)
tells the writablestream and its writer when to resolve defaultwriter.ready.
How to check the security state of an XMLHTTPRequest over SSL - Web APIs
by setting the mozbackgroundrequest property of the request object and modifying the example appropria
tely, you can create your own alert dialog to handle ssl exceptions in your firefox extension or xulrunner application.
...nsserrorsservice.nss_sec_error_base) - (status & 0xffff); switch (nsserr) { case 11: // sec_error_expired_certificate, sec(11) errname = 'securityexpiredcertificateerror'; break; case 12: // sec_error_revoked_certificate, sec(12) errname = 'securityrevokedcertificateerror'; break; // per bsmith, we will be unable to
tell these errors apart very soon, // so it makes sense to just folder them all together already.
XRReferenceSpace.getOffsetReferenceSpace() - Web APIs
teleporting or setting the position of the viewer upon first creating a scene, you may need to set the user's position within the 3d world.
...applymousemovement() should be called when drawing a frame, immedia
tely before fetching the viewer's pose using getviewerpose(), and the rendering should be performed in this reference space.
XRReferenceSpace: reset event - Web APIs
however, if that kind of "
teleportation" is being used, you actually want to avoid jumping the user's position after tracking recovery, this can introduce additional and potentially jarring jumping.
... instead of allowing this to happen, you can integrate the emulatedposition into the
teleportation offset calculated prior to calling getoffsetreferencespace() to create a new reference space whose updated effective origin is adjusted by the distance the viewer's position jumped since the previous frame.
XRSession - Web APIs
the select event is sent after the selectstart event is sent and immedia
tely before the selectend event is sent.
...it is sent immedia
tely before the squeezeend event is sent to indicate that the squeeze action is over.
XRViewerPose - Web APIs
for example, every player in a mmorpg might have an instance of xrviewerpose to provide a way to calculate what they can see; if the game provides a mechanism that
tells the player if another player sees them, or that they see another player, this information becomes crucial.
...the returned xrviewerpose
tells you where the viewer is and what direction they're facing at the time at which the frame takes place.
XRWebGLLayerInit.ignoreDepthValues - Web APIs
the depth buffer is typically used to assist in ordering vertices and, by extension, polygons while compositing, to ensure that the scene is correctly composited, with objects the correct distance away and with clipping and other distance-related computations performed as accura
tely as possible.
... using a depth buffer while compositing allows the xr compositor to help ensure the compositing is done as accura
tely as possible.
ARIA live regions - Accessibility
<div id="clock" role="timer" aria-live="polite"></div> /* basic javascript to update the clock */ setinterval(function() { var now = new date(); document.ge
telementbyid('clock').innerhtml = "time: " + now.gethours() + ":" + ("0"+now.getminutes()).substr(-2); }, 60000); the first time the function executes, the entirety of the string that is added will be announced.
... a working example of a simple year control for better understanding: <div id="date-input"> <label>year: <input type="text" id="year" value="1990" onblur="change(event)"/> </label> </div> <div id="date-output" aria-live="polite"> the set year is: <span id="year-output">1990</span> </div> function change(event) { var yearout = document.ge
telementbyid("year-output"); switch (event.target.id) { case "year": yearout.innerhtml = event.target.value; break; default: return; } }; without aria-atomic="true" the screenreader announces only the changed value of year.
Using the link role - Accessibility
> fake accessible link created using a span </span> <p><a href="https://mozilla.org" target="_blank">actual real link</a></p> css span[role="link"] { color: blue; text-decoration: underline; cursor: pointer; } span[role="link"]:focus { outline: 1px dotted black; } javascript const spanelem = document.queryselector('span'); //handles clicks and keydowns on the link function naviga
telink(e) { if (e.type === 'click' || e.key === 'enter') { let ref = e.target != null ?
... e.target : e.srcelement; if (ref) { window.open(ref.getattribute('data-href'), '_blank'); } } } spanelem.addeventlistener('click', naviga
telink); spanelem.addeventlistener('keydown', naviga
telink); result notes if pressing the link triggers an action but does not change browser focus or navigate to a new page, you might wish to consider using the button role instead of the link role.
ARIA - Accessibility
unfortuna
tely, there isn't a more semantic tag available to developers in html 4, so we need to include aria roles and properties.
...var progressbar = document.ge
telementbyid("percent-loaded"); // set its aria roles and states, // so that assistive technologies know what kind of widget it is.
Keyboard-navigable JavaScript widgets - Accessibility
the event handler on the container must respond to key and mouse events by updating the value of aria-activedescendant and ensuring that the current item is styled appropria
tely (for example, with a border or background color).
... don't rely on consistent behavior for key repeat, at this point unfortuna
tely onkeydown may or may not repeat depending on what browser and os you're running on.
Web accessibility for seizures and physical reactions - Accessibility
the point is, seizures most defini
tely can be and are fatal, and developers and designers are incredibly important to making the web a safer place for those with sensitivities to photosensitive or musicogenic triggers.
...the epilepsy foundation's article, photosensitivity and seizures, provides a list of triggers that may cause seizures in photosensitive people; here's an excerpt from that list:
television screens or computer monitors due to the flicker or rolling images.
Operable - Accessibility
completing a ho
tel or flight booking often has a time limit), the user should be given controls to allow them to adjust, extend or turn off the time limit.
... 2.4.10 section headings (aaa) as well as creating a useful document structure, headings should also accura
tely describe and break up content areas into logical sections.
-webkit-overflow-scrolling - CSS: Cascading Style Sheets
syntax values auto use "regular" scrolling, where the content immedia
tely ceases to scroll when you remove your finger from the touchscreen.
... </p> </div> css div { width: 100%; overflow: auto; } p { width: 200%; background: #f5f9fa; border: 2px solid #eaf2f4; padding: 10px; } .scroll-touch { -webkit-overflow-scrolling: touch; /* lets it scroll lazy */ } .scroll-auto { -webkit-overflow-scrolling: auto; /* stops scrolling immedia
tely */ } results specifications not part of any standard.
:scope - CSS: Cascading Style Sheets
javascript let paragraph = document.ge
telementbyid("para"); let output = document.ge
telementbyid("output"); if (paragraph.matches(":scope")) { output.innertext = "yep, the element is its own scope as expected!"; } html <p id="para"> this is a paragraph.
... javascript var context = document.ge
telementbyid('context'); var selected = context.queryselectorall(':scope > div'); document.ge
telementbyid('results').innerhtml = array.prototype.map.call(selected, function (element) { return '#' + element.getattribute('id'); }).join(', '); html <div id="context"> <div id="element-1"> <div id="element-1.1"></div> <div id="element-1.2"></div> </div> <div id="element-2"> <div id="element-2.1"></div> </div> </div> <p> selected elements ids : <span id="results"></sp...
height - CSS: Cascading Style Sheets
if the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolu
tely positioned, the percentage value is treated as 0.max-height: the percentage is calculated with respect to the height of the generated box's containing block.
... if the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolu
tely positioned, the percentage value is treated as none.computed valueas each of the properties of the shorthand:min-height: the percentage as specified or the absolute lengthmax-height: the percentage as specified or the absolute length or none formal syntax <viewport-length>{1,2}where <viewport-length> = auto | <length-percentage>where <length-percentage> = <length> | <percentage> examples setting minimum and maximum height @viewport { height: 500px; } specifications specification status comment css device adaptationthe definition of '"height" descriptor' in that specification.
Adjacent sibling combinator - CSS: Cascading Style Sheets
the adjacent sibling combinator (+) separates two selectors and matches the second element only if it immedia
tely follows the first element, and both are children of the same parent element.
... /* paragraphs that come immedia
tely after any image */ img + p { font-weight: bold; } syntax former_element + target_element { style properties } examples css li:first-of-type + li { color: red; } html <ul> <li>one</li> <li>two!</li> <li>three</li> </ul> result specifications specification status comment selectors level 4the definition of 'next-sibling combinator' in that specification.
Alternative style sheets - CSS: Cascading Style Sheets
when the user selects a different style, the page will immedia
tely be re-rendered using that style sheet.
...this
tells the browser which style sheet title should be selected by default, and makes that default selection apply in browsers that do not support alternate style sheets.
Using multi-column layouts - CSS: Cascading Style Sheets
unfortuna
tely this is impossible to do with css and html without forcing column breaks at fixed positions, or severely restricting the markup allowed in the text, or using heroic scripting.
...pteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </div> css #columns_12 { columns: 12 8em; } result height balancing the css3 column specification requires that the column heights must be balanced: that is, the browser automatically sets the maximum column height so that the heights of the content in each column are approxima
tely equal.
Backwards Compatibility of Flexbox - CSS: Cascading Style Sheets
however, prefixes ultima
tely were used in production code, and changes to the experimental specification caused people to need to update their sites to keep up.
... ultima
tely the specification was updated to define display: flex as the way to create a flex container.
Block and inline layout in normal flow - CSS: Cascading Style Sheets
this means that if you have an element with a top margin immedia
tely after an element with a bottom margin, rather than the total space being the sum of these two margins, the margin collapses, and so will essentially become as large as the larger of the two margins.
... this concept of the outer and inner display type is important as this
tells us that a container using a layout method such as flexbox (display: flex) and grid layout (display: grid) is still participating in block and inline layout, due to the outer display type of those methods being block.
Introduction to formatting contexts - CSS: Cascading Style Sheets
a new bfc is created in the following situations: elements made to float using float absolu
tely positioned elements (including position: fixed or position: sticky) elements with display: inline-block table cells or elements with display: table-cell, including anonymous table cells created when using the display: table-* properties table captions or elements with display: table-caption block elements where overflow has a value other than visible elements with display: flow-root or disp...
... the problem with using overflow to create a new bfc is that the overflow property is meant for
telling the browser how you wish to deal with overflowing content.
Auto-placement in CSS Grid Layout - CSS: Cascading Style Sheets
in addition to the ability to place items accura
tely onto a created grid, the css grid layout specification contains rules that control what happens when you create a grid and do not place some or all of the child items.
...this can be helpful, if you have a document order that reflects the order in which items sit on the grid you may not need to write css rules to place absolu
tely everything.
Box alignment in CSS Grid Layout - CSS: Cascading Style Sheets
this is in contrast to omitting align-items comple
tely, in which case the height of each <div> stretches to fill its grid area.
... setting auto margins, using margin-right or margin-left however, or absolu
tely positioning items using the top, right, bottom and left offsets would not honor writing modes.
Stacking context example 3 - CSS: Cascading Style Sheets
the second-level menu is absolu
tely positioned inside the parent element.
... note: in the source code you will see that second-level and third level menus are made of several divs contained in an absolu
tely positioned container.
The stacking context - CSS: Cascading Style Sheets
each stacking context is comple
tely independent of its siblings: only descendant elements are considered when stacking is processed.
...the hierarchy of stacking contexts is organized as follows: root div #1 div #2 div #3 div #4 div #5 div #6 it is important to note that div #4, div #5 and div #6 are children of div #3, so stacking of those elements is comple
tely resolved within div#3.
Basic concepts of CSS Scroll Snap - CSS: Cascading Style Sheets
the mandatory keyword
tells the browser whether the content has to snap to a certain point, no matter where the scroll is.
... the scroll-snap-stop property the scroll-snap-stop property
tells the browser whether it should snap to each defined snap point — meaning that in our examples above we would stop at the start of each section — or be able to skip past sections.
CSS selectors - CSS: Cascading Style Sheets
this means that the second element follows the first (though not necessarily immedia
tely), and both share the same parent.
... syntax: a ~ b example: p ~ span will match all <span> elements that follow a <p>, immedia
tely or not.
CSS values and units - CSS: Cascading Style Sheets
otherwise, the unit identifier is required, is case insensitive, and must come immedia
tely after the numeric part of the value, with no space in-between.
...the syntax starts with the name of the function immedia
tely followed by a left parenthesis ( followed by the argument(s) to the notation followed by a right parenthesis ).
CSS reference - CSS: Cascading Style Sheets
combinators combinators are selectors that establish a relationship between two or more simple selectors, such as "a is a child of b" or "a is adjacent to b." adjacent sibling combinator a + b specifies that the elements selected by both a and b have the same parent and that the element selected by b immedia
tely follows the element selected by a horizontally.
... general sibling combinator a ~ b specifies that the elements selected by both a and b share the same parent and that the element selected by a comes before—but not necessarily immedia
tely before—the element selected by b.
<blend-mode> - CSS: Cascading Style Sheets
any change occurs immedia
tely.
...n>exclusion</option> <option>hue</option> <option>saturation</option> <option>color</option> <option>luminosity</option> </select> css div { width: 300px; height: 300px; background: url(https://media.prod.mdn.mozit.cloud/attachments/2020/07/29/17350/3b4892b7e820122ac6dd7678891d4507/firefox.png) no-repeat center, linear-gradient(to bottom, blue, orange); } javascript const selec
telem = document.queryselector('select'); const divelem = document.queryselector('div'); selec
telem.addeventlistener('change', () => { divelem.style.backgroundblendmode = selec
telem.value; }); result specifications specification status comment compositing and blending level 1the definition of '<blend-mode>' in that specification.
bottom - CSS: Cascading Style Sheets
syntax /* <length> values */ bottom: 3px; bottom: 2.4em; /* <percentage>s of the height of the containing block */ bottom: 10%; /* keyword value */ bottom: auto; /* global values */ bottom: inherit; bottom: initial; bottom: unset; values <length> a negative, null, or positive <length> that represents: for absolu
tely positioned elements, the distance to the bottom edge of the containing block.
... auto specifies that: for absolu
tely positioned elements, the position of the element is based on the top property, while height: auto is treated as a height based on the content; or if top is also auto, the element is positioned where it should vertically be positioned if it were a static element.
clamp() - CSS: Cascading Style Sheets
pellentesque convallis ante nec augue porttitor, id tempus ante luctus.</p> <p>integer rutrum sollicitudin
tellus, quis cursus nulla scelerisque nec.
...maecenas faucibus sapien eleifend, semper
tellus at, pharetra quam.
clip - CSS: Cascading Style Sheets
the clip property applies only to absolu
tely positioned elements — that is, elements with position:absolute or position:fixed.
... formal definition initial valueautoapplies toabsolu
tely positioned elementsinheritednocomputed valueauto if specified as auto, otherwise a rectangle with four values, each of which is auto if specified as auto or the computed length otherwiseanimation typea rectangle formal syntax <shape> | autowhere <shape> = rect(<top>, <right>, <bottom>, <left>) examples clipping an image css .dotted-border { border: dotted; position: relative; width: ...
<dimension> - CSS: Cascading Style Sheets
syntax the syntax of <dimension> is a <number> immedia
tely followed by a unit which is an identifier.
... examples valid dimensions 12px 12 pixels 1rem 1 rem 1.2pt 1.2 points 2200ms 2200 milliseconds 5s 5 seconds 200hz 200 hertz 200hz 200 hertz (values are case insensitive) invalid dimensions 12 px the unit must come immedia
tely after the number.
Adapting to the new two-value syntax of display - CSS: Cascading Style Sheets
the new syntax accura
tely describes what is happening with this value.
...if you consider the outer and inner values when you change the value of display, you will understand immedia
tely what impact the value will have on the box itself, and how it displays and behaves in the layout, and the direct children.
brightness() - CSS: Cascading Style Sheets
a value of 0% will create an image that is comple
tely black, while a value of 100% leaves the input unchanged.
... examples setting brightness using numbers and percentages brightness(0%) /* comple
tely black */ brightness(0.4) /* 40% brightness */ brightness(1) /* no effect */ brightness(200%) /* double brightness */ specifications specification status filter effects module level 1the definition of 'brightness()' in that specification.
contrast() - CSS: Cascading Style Sheets
a value of 0% will create an image that is comple
tely gray, while a value of 100% leaves the input unchanged.
... examples setting contrast using numbers and percentages contrast(0) /* comple
tely gray */ contrast(65%) /* 65% contrast */ contrast(1) /* no effect */ contrast(200%) /* double contrast */ specifications specification status filter effects module level 1the definition of 'contrast()' in that specification.
grayscale() - CSS: Cascading Style Sheets
a value of 100% is comple
tely grayscale, while a value of 0% leaves the input unchanged.
... examples grayscale(0) /* no effect */ grayscale(.7) /* 70% grayscale */ grayscale(100%) /* comple
tely grayscale */ specifications specification status filter effects module level 1the definition of 'grayscale()' in that specification.
invert() - CSS: Cascading Style Sheets
a value of 100% is comple
tely inverted, while a value of 0% leaves the input unchanged.
... examples invert(0) /* no effect */ invert(.6) /* 60% inversion */ invert(100%) /* comple
tely inverted */ specifications specification status filter effects module level 1the definition of 'invert()' in that specification.
opacity() - CSS: Cascading Style Sheets
a value of 0% is comple
tely transparent, while a value of 100% leaves the input unchanged.
... examples opacity(0%) /* comple
tely transparent */ opacity(50%) /* 50% transparent */ opacity(1) /* no effect */ specifications specification status filter effects module level 1the definition of 'opacity()' in that specification.
saturate() - CSS: Cascading Style Sheets
a value of 0% is comple
tely unsaturated, while a value of 100% leaves the input unchanged.
... examples saturate(0) /* comple
tely unsaturated */ saturate(.4) /* 40% saturated */ saturate(100%) /* no effect */ saturate(200%) /* double saturation */ specifications specification status filter effects module level 1the definition of 'saturate()' in that specification.
sepia() - CSS: Cascading Style Sheets
a value of 100% is comple
tely sepia, while a value of 0% leaves the input unchanged.
... examples sepia(0) /* no effect */ sepia(.65) /* 65% sepia */ sepia(100%) /* comple
tely sepia */ specifications specification status filter effects module level 1the definition of 'sepia()' in that specification.
font-optical-sizing - CSS: Cascading Style Sheets
when optical sizing is used, small text sizes are often rendered with thicker strokes and larger serifs, whereas larger text is often rendered more delica
tely with more contrast between thicker and thinner strokes.
... you should see a difference in supporting browsers.</p> @font-face { src: url('ams
telvaralpha-vf.ttf'); font-family:'ams
telvar'; font-style: normal; } p { font-size: 36px; font-family: ams
telvar; } .no-optical-sizing { font-optical-sizing: none; } note: the font referenced above — which includes optical sizing and is freely-licensed — is good for testing.
font-style - CSS: Cascading Style Sheets
html <header> <input type="range" id="slant" name="slant" min="-90" max="90" /> <label for="slant">slant</label> </header> <div class="container"> <p class="sample">...it would not be wonderful to meet a megalosaurus, forty feet long or so, waddling like an elephantine lizard up holborn hill.</p> </div> css /* ams
telvaralpha-vf is created by david berlow (https://github.com/typenetwork/ams
telvar) and is used here under the terms of its license: https://github.com/typenetwork/ams
telvar/blob/master/ofl.txt */ @font-face { src: url('https://mdn.mozillademos.org/files/16044/ams
telvaralpha-vf.ttf'); font-family:'ams
telvaralpha'; font-style: normal; } label { font: 1rem monospace; } .container { max-he...
...ight: 150px; overflow: scroll; } .sample { font: 2rem 'ams
telvaralpha', sans-serif; } html, body { max-height: 100vh; max-width: 100vw; overflow: hidden; } body { display: flex; flex-direction: column; } header { margin-bottom: 1.5rem; } .container { flex-grow: 1; } .container > p { margin-top: 0; margin-bottom: 0; } javascript let slantlabel = document.queryselector('label[for="slant"]'); let slantinput = document.queryselector('#slant'); let sampletext = document.queryselector('.sample'); function update() { let slant = `oblique ${slantinput.value}deg`; slantlabel.textcontent = `font-style: ${slant};`; sampletext.style.fontstyle = slant; } slantinput.addeventlistener('input', update); update(); accessibility concerns large sections of text set...
image-orientation - CSS: Cascading Style Sheets
from-image the exif information contained in the image will be used to rotate the image appropria
tely.
...ata css #image { image-orientation: from-image; /* can be changed in the live sample */ } html <img id="image" src="https://udn.realityripple.com/samples/db/4f9fbd7dfb.svg" alt="orientation taken from the image"> <select id="imageorientation"> <option value="from-image">from-image</option> <option value="none">none</option> </select> javascript var imageorientation = document.ge
telementbyid("imageorientation"); imageorientation.addeventlistener("change", function (evt) { document.ge
telementbyid("image").style.imageorientation = evt.target.value; }); result specifications specification status comment css images module level 3the definition of 'image-orientation' in that specification.
left - CSS: Cascading Style Sheets
syntax /* <length> values */ left: 3px; left: 2.4em; /* <percentage>s of the width of the containing block */ left: 10%; /* keyword value */ left: auto; /* global values */ left: inherit; left: initial; left: unset; values <length> a negative, null, or positive <length> that represents: for absolu
tely positioned elements, the distance to the left edge of the containing block.
... auto specifies that: for absolu
tely positioned elements, the position of the element is based on the right property, while width: auto is treated as a width based on the content; or if right is also auto, the element is positioned where it should horizontally be positioned if it were a static element.
<length> - CSS: Cascading Style Sheets
; display: flex; align-items: center; margin-top: 10px; } .result code { position: absolute; margin-left: 20px; } .results { margin-top: 10px; } .input-container { position: absolute; display: flex; justify-content: flex-start; align-items: center; height: 50px; } label { margin: 0 10px 0 20px; } javascript const inputdiv = document.queryselector('.inner'); const inpu
telem = document.queryselector('input'); const resultsdiv = document.queryselector('.results'); inpu
telem.addeventlistener('change', () => { inputdiv.style.width = inpu
telem.value; const result = document.createelement('div'); result.classname = 'result'; result.style.width = inpu
telem.value; result.innerhtml = `<code>width: ${inpu
telem.value}</code>`; resultsdiv.appendchild(result); ...
... inpu
telem.value = ''; inpu
telem.focus(); }) result specifications specification status comment css values and units module level 4the definition of '<length>' in that specification.
order - CSS: Cascading Style Sheets
flexbox & the keyboard navigation disconnect — tink source order matters | adrian roselli mdn understanding wcag, guideline 1.3 explanations understanding success criterion 1.3.2 | w3c understanding wcag 2.0 formal definition initial value0applies toflex items and absolu
tely-positioned flex container childreninheritednocomputed valueas specifiedanimation typean integer formal syntax <integer> examples ordering items in a flex container this example uses css to create a classic two-sidebar layout surrounding a content block.
... candidate recommendation initial definition initial value0applies toflex items and absolu
tely-positioned flex container childreninheritednocomputed valueas specifiedanimation typean integer ...
place-content - CSS: Cascading Style Sheets
r</option> <option value="start">start</option> <option value="end">end</option> <option value="flex-start">flex-start</option> <option value="flex-end">flex-end</option> <option value="left">left</option> <option value="right">right</option> <option value="safe">safe</option> <option value="unsafe">unsafe</option> </select><code>;</code> var update = function () { document.ge
telementbyid("container").style.placecontent = document.ge
telementbyid("aligncontentalignment").value + " " + document.ge
telementbyid("justifycontentalignment").value; } var aligncontentalignment = document.ge
telementbyid("aligncontentalignment"); aligncontentalignment.addeventlistener("change", update); var justifycontentalignment = document.ge
telementbyid("justifycontentalignment"); justifyconte...
...ntalignment.addeventlistener("change", update); var writingm = document.ge
telementbyid("writingmode"); writingm.addeventlistener("change", function (evt) { document.ge
telementbyid("container").style.writingmode = evt.target.value; }); var direction = document.ge
telementbyid("direction"); direction.addeventlistener("change", function (evt) { document.ge
telementbyid("container").style.direction = evt.target.value; }); css #container { display: flex; height:240px; width: 240px; flex-wrap: wrap; background-color: #8c8c8c; writing-mode: horizontal-tb; /* can be changed in the live sample */ direction: ltr; /* can be changed in the live sample */ place-content: flex-end center; /* can be changed in the live sample */ } div > div { border: 2px solid #8c8c8c; width: 50...
text-underline-position - CSS: Cascading Style Sheets
aliquam accumsan
tellus ac erat posuere.</p> <p class="vertical">lorem ipsum dolor sit amet, consectetur adipiscing elit.
...aliquam accumsan
tellus ac erat posuere.</p> our css looks like this: p { font-size: 1.5rem; text-transform: capitalize; text-decoration: underline; text-decoration-thickness: 2px; } .horizontal { text-underline-position: under; } .vertical { writing-mode: vertical-rl; text-underline-position: left; } in this example we set both the paragraphs to have a thick underline.
top - CSS: Cascading Style Sheets
syntax /* <length> values */ top: 3px; top: 2.4em; /* <percentage>s of the height of the containing block */ top: 10%; /* keyword value */ top: auto; /* global values */ top: inherit; top: initial; top: unset; values <length> a negative, null, or positive <length> that represents: for absolu
tely positioned elements, the distance to the top edge of the containing block.
... auto specifies that: for absolu
tely positioned elements, the position of the element is based on the bottom property, while height: auto is treated as a height based on the content; or if bottom is also auto, the element is positioned where it should vertically be positioned if it were a static element.
<transform-function> - CSS: Cascading Style Sheets
the translation vector (tx, ty) must be expressed separa
tely, as two additional parameters.
...ba(210,0,0,.7); transform: rotatey(90deg) translatez(50px); } .left { background: rgba(0,0,210,.7); transform: rotatey(-90deg) translatez(50px); } .top { background: rgba(210,210,0,.7); transform: rotatex(90deg) translatez(50px); } .bottom { background: rgba(210,0,210,.7); transform: rotatex(-90deg) translatez(50px); } .select-form { margin-top: 50px; } javascript const selec
telem = document.queryselector('select'); const example = document.queryselector('#example-element'); selec
telem.addeventlistener('change', () => { if(selec
telem.value === 'choose a function') { return; } else { example.style.transform = `rotate3d(1, 1, 1, 30deg) ${selec
telem.value}`; settimeout(function() { example.style.transform = 'rotate3d(1, 1, 1, 30deg)'; }, 2000) }...
transition-delay - CSS: Cascading Style Sheets
the delay may be zero, positive, or negative: a value of 0s (or 0ms) will begin the transition effect immedia
tely.
... a negative value will begin the transition effect immedia
tely, and partway through the effect.
WAI ARIA Live Regions/API Support - Developer guides
ut to go away) object shown or inserted children_changed::add (fired on the parent, with event data pointing to the child index of the inserted accessible object) event_object_show* (fired on the actual new accessible object) object replaced with different object (this happens especially if an object's interfaces or role changes) children_changed::remove followed immedia
tely by children_change::add event_object_hide followed immedia
tely by event_object_show text removed text_changed::delete ia2_event_text_removed (use iaccessibletext::get_oldtext to retrieve the offsets and removed text) text inserted text_changed::insert ia2_event_text_inserted (use iaccessibletext::get_newtext to retrieve the offsets and inserted text) tex...
...t replaced text_changed::delete followed immedia
tely by text_changed::insert ia2_event_text_removed followed immedia
tely by ia2_event_text_inserted * we do not use msaa's create/destroy at the request of screen reader vendors, who avoid those events because they cause crashes on some important system -- show/hide are the equivalent of those events.
Video player styling basics - Developer guides
as mentioned in the previous article, there is a fallback provided for browsers that do not support the <progress> element; this also needs to be styled appropria
tely: .controls progress[data-state="fake"] { background:#e6e6e6; height:65%; } .controls progress span { width:0%; height:100%; display:inline-block; background-color:#2a84cd; } a .data-state class is also used here when a <progress> element is being "faked"; when it's in this state the background colour needs to be set.
... there are some browser-specific properties that need to be set to ensure that firefox and chrome use the required colour for the progress bar: .controls progress::-moz-progress-bar { background-color:#0095dd; } .controls progress::-webkit-progress-value { background-color:#0095dd; } although the same properties are set to the same value, these rules need to be defined separa
tely, otherwise chrome ignores it.
Audio and Video Delivery - Developer guides
to grab the stream from your webcam, first set up a <video> element: <video id="webcam" width="480" height="360"></video> next, if supported connect the webcam source to the video element: if (navigator.mediadevices) { navigator.mediadevices.getusermedia({ video: true, audio: false }) .then(function onsuccess(stream) { var video = document.ge
telementbyid('webcam'); video.autoplay = true; video.srcobject = stream; }) .catch(function onerror() { alert('there has been a problem retreiving the streams - are you running on file:/// or did you disallow access?'); }); } else { alert('getusermedia is not supported in this browser.'); } to find out more, read our mediadevices.getusermedia page.
... a quick example — first set up your audio and custom controls in html: <audio id="my-audio" src="http://jplayer.org/audio/mp3/miaow-01-tempered-song.mp3"></audio> <button id="my-control">play</button> add a bit of javascript to detect events to play and pause the audio: window.onload = function() { var myaudio = document.ge
telementbyid('my-audio'); var mycontrol = document.ge
telementbyid('my-control'); function switchstate() { if (myaudio.paused == true) { myaudio.play(); mycontrol.innerhtml = "pause"; } else { myaudio.pause(); mycontrol.innerhtml = "play"; } } function checkkey(e) { if (e.keycode == 32 ) { //spacebar switchstate(); } } mycontrol.addevent...
Block formatting context - Developer guides
absolu
tely positioned elements (elements where position is absolute or fixed).
... the problem with using overflow to create a new bfc is that the overflow property is meant for
telling the browser how you want to deal with overflowing content.
Localizations and character encodings - Developer guides
unfortuna
tely, using utf-8 and declaring that utf-8 was used was not always the prevalent way of offering web content.
... unfortuna
tely, this means that the web-exposed functionality of firefox differs by locale and it is hard to read legacy content across locales with different fallback encodings.
A hybrid approach - Developer guides
if your mobile and desktop use cases are similar enough, this is defini
tely the preferred option for layout changes.
...instead of maintaining two comple
tely different sites, we simply redirect users to pages for the content they care about.
HTML attribute: required - HTML: Hypertext Markup Language
the required attribute is supported by text, search, url,
tel, email, password, date, month, week, time, datetime-local, number, checkbox, radio, file, <input> types along with the <select> and <textarea> form control elements.
... note: setting aria-required="true"
tells a screen reader that an element (any element) is required, but has no bearing on the optionality of the element.
<dialog>: The Dialog element - HTML: Hypertext Markup Language
option>red panda</option> <option>spider monkey</option> </select> </label></p> <menu> <button value="cancel">cancel</button> <button id="confirmbtn" value="default">confirm</button> </menu> </form> </dialog> <menu> <button id="updatedetails">update details</button> </menu> <output aria-live="polite"></output> javascript var updatebutton = document.ge
telementbyid('updatedetails'); var favdialog = document.ge
telementbyid('favdialog'); var outputbox = document.queryselector('output'); var selec
tel = document.queryselector('select'); var confirmbtn = document.ge
telementbyid('confirmbtn'); // "update details" button opens the <dialog> modally updatebutton.addeventlistener('click', function onopen() { if (typeof favdialog.showmodal === "function") ...
...{ favdialog.showmodal(); } else { alert("the <dialog> api is not supported by this browser"); } }); // "favorite animal" input sets the value of the submit button selec
tel.addeventlistener('change', function onselect(e) { confirmbtn.value = selec
tel.value; }); // "confirm" button of form triggers "close" on dialog because of [method="dialog"] favdialog.addeventlistener('close', function onclose() { outputbox.value = favdialog.returnvalue + " button clicked - " + (new date()).tostring(); }); result specifications specification status comment html living standardthe definition of '<dialog>' in that specification.
<img>: The Image Embed element - HTML: Hypertext Markup Language
intrinsicsize this attribute
tells the browser to ignore the actual intrinsic size of the image and pretend it’s the size specified in the attribute.
... loading indicates how the browser should load the image: eager: loads the image immedia
tely, regardless of whether or not the image is currently within the visible viewport (this is the default value).
<input type="week"> - HTML: Hypertext Markup Language
its value can, however, still be changed by javascript code directly setting the htmlinpu
telement.value property.
...to detect whether the browser supports <input type="week">, we create a new <input> element, try setting its type to week, then immedia
tely check what its type is set to.
<link>: The External Resource Link element - HTML: Hypertext Markup Language
integrity contains inline metadata — a base64-encoded cryptographic hash of the resource (file) you’re
telling the browser to fetch.
...eet'); mystylesheet.onload = function() { // do something interesting; the sheet has been loaded } mystylesheet.onerror = function() { console.log("an error occurred loading the stylesheet!"); } </script> <link rel="stylesheet" href="mystylesheet.css" id="my-stylesheet"> note: the load event fires once the stylesheet and all of its imported content has been loaded and parsed, and immedia
tely before the styles start being applied to the content.
<object> - HTML: Hypertext Markup Language
implicit aria role no corresponding role permitted aria roles application, document, image dom interface htmlobjec
telement attributes this element includes the global attributes.
...in html5, repeat the <object> element comple
tely each that that the resource is reused.
<ol>: The Ordered List element - HTML: Hypertext Markup Language
implicit aria role list permitted aria roles directory, group, listbox, menu, menubar, none, presentation, radiogroup, tablist, toolbar, tree dom interface htmlolis
telement attributes this element also accepts the global attributes.
... html5the definition of 'htmlolis
telement' in that specification.
<rb>: The Ruby Base element - HTML: Hypertext Markup Language
tag omission the end tag can be omitted if the element is immedia
tely followed by an <rt>, <rtc>, or <rp> element or another <rb> element, or if there is no more content in the parent element.
... note that we could also write this example with the two base text parts annotated comple
tely separa
tely.
<tbody>: The Table Body element - HTML: Hypertext Markup Language
when a table is presented in a screen context (such as a window) which is not large enough to display the entire table, the user agent may let the user scroll the contents of the <thead>, <tbody>, <tfoot>, and <caption> blocks separa
tely from one another for the same parent table.
...this lets you divide the rows in large tables into sections, each of which may be separa
tely formatted if so desired.
<template>: The Content Template element - HTML: Hypertext Markup Language
the html content template (<template>) element is a mechanism for holding html that is not to be rendered immedia
tely when a page is loaded but may be instantiated subsequently during runtime using javascript.
... consider the following html and javascript: html <div id="container"></div> <template id="template"> <div>click me</div> </template> javascript const container = document.ge
telementbyid("container"); const template = document.ge
telementbyid("template"); function clickhandler(event) { alert("clicked a div"); } const firstclone = template.content.clonenode(true); firstclone.addeventlistener("click", clickhandler); container.appendchild(firstclone); const secondclone = template.content.firs
telementchild.clonenode(true); secondclone.addeventlistener("click", clickhandl...
inputmode - HTML: Hypertext Markup Language
tel a
telephone keypad input, including the digits 0–9, the asterisk (*), and the pound (#) key.
... inputs that require a
telephone number should typically use <input type="
tel">instead.
Global attributes - HTML: Hypertext Markup Language
classes allows css and javascript to select and access specific elements via the class selectors or functions like the method document.ge
telementsbyclassname().
...this attribute must not be used to hide content that could legitima
tely be shown.
Choosing between www and non-www URLs - HTTP
this has no impact on the human reader of the page, but
tells search engine crawlers where the page actually lives.
... when adding such a tag, you serve the same content for both domains,
telling search engines which url is canonical.
Compression in HTTP - HTTP
in practice, web developers don't need to implement compression mechanisms, both browsers and servers have it implemented already, but they have to be sure that the server is configured adequa
tely.
...the browser sends an accept-encoding header with the algorithm it supports and its order of precedence, the server picks one, uses it to compress the body of the response and uses the content-encoding header to
tell the browser the algorithm it has chosen.
Configuring servers for Ogg media - HTTP
consider using the preload attribute the html <audio> and <video> elements provide the preload attribute, which
tells the browser to attempt to download the entire media when the page loads.
...setting payload to auto
tells the browser to automatically begin downloading the media as soon as the page is loaded, under the assumption that the user will play it.
Content negotiation - HTTP
the vary header was added in the version 1.1 of http and is necessary in order to allow caches to work appropria
tely.
... unfortuna
tely, the http standard does not specify the format of the page allowing to choose between the available resource, which prevents to easily automatize the process.
Access-Control-Allow-Origin - HTTP
header type response header forbidden header name no syntax access-control-allow-origin: * access-control-allow-origin: <origin> access-control-allow-origin: null directives * for requests without credentials, the literal value "*" can be specified, as a wildcard; the value
tells browsers to allow requesting code from any origin to access the resource.
...the "null" value for the acao header should therefore be avoided." examples a response that
tells the browser to allow code from any origin to access a resource will include the following: access-control-allow-origin: * a response that
tells the browser to allow requesting code from the origin https://developer.mozilla.org to access a resource will include the following: access-control-allow-origin: https://developer.mozilla.org limiting the possible access-control-allow-origin values t...
CSP: child-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
CSP: font-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
CSP: frame-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
CSP: manifest-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
CSP: media-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
CSP: object-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
CSP: style-src - HTTP
use this sparingly and defini
tely not for scripts.
...however, if you absolu
tely have to use it, there are a few mechanisms that will allow them.
CSP: worker-src - HTTP
use this sparingly and defini
tely not for scripts.
... 'nonce-<base64-value>' a whi
telist for specific inline scripts using a cryptographic nonce (number used once).
Content-Type - HTTP
in responses, a content-type header
tells the client what the content type of the returned content actually is.
... in requests, (such as post or put), the client
tells the server what type of data is actually sent.
ETag - HTTP
they might also be set to persist indefini
tely by a tracking server.
... the client will send the value of its etag along in an if-none-match header field: if-none-match: "33a64df551425fcc55e4d42a148795d9f25f89d4" the server compares the client's etag (sent with if-none-match) with the etag for its current version of the resource, and if both values match (that is, the resource has not changed), the server sends back a 304 not modified status, without a body, which
tells the client that the cached version of the response is still good to use (fresh).
Large-Allocation - HTTP
the non-standard large-allocation response header
tells the browser that the page being loaded is going to want to perform a large allocation.
...the large-allocation
tells the browser that the web content in the to-be-loaded page is going to want to perform a large contiguous memory allocation and the browser can react to this header by starting a dedicated process for the to-be-loaded document, for example.
User-Agent - HTTP
examples mozilla/5.0 (windows nt 6.1; win64; x64; rv:47.0) gecko/20100101 firefox/47.0 mozilla/5.0 (macintosh; in
tel mac os x x.y; rv:42.0) gecko/20100101 firefox/42.0 chrome ua string the chrome (or chromium/blink-based engines) user agent string is similar to firefox’s.
... examples mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, like gecko) chrome/51.0.2704.106 safari/537.36 opr/38.0.2220.41 older, presto-based opera releases used: opera/9.80 (macintosh; in
tel mac os x; u; en) presto/2.2.15 version/10.00 opera/9.60 (windows nt 6.0; u; en) presto/2.1.1 safari ua string in this example, the user agent string is mobile safari’s version.
OPTIONS - HTTP
in this example, we will request permission for these parameters: the access-control-request-method header sent in the preflight request
tells the server that when the actual request is sent, it will have a post request method.
... the access-control-request-headers header
tells the server that when the actual request is sent, it will have the x-pingother and content-type headers.
Redirections in HTTP - HTTP
when browsers receive a redirect, they immedia
tely load the new url provided in the location header.
... it is important to avoid redirection loops, as they comple
tely break the user experience.
A typical HTTP session - HTTP
http://developer.mozilla.org/, and
telling the server that the user-agent would prefer the page in french, if possible: get / http/1.1 host: developer.mozilla.org accept-language: fr observe that final empty line, this separates the data block from the header block.
... structure of a server response after the connected agent has sent its request, the web server processes it, and ultima
tely returns a response.
HTTP response status codes - HTTP
205 reset content
tells the user-agent to reset the document which sent this request.
...it
tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.
A re-introduction to JavaScript (JS tutorial) - JavaScript
more accura
tely, they are sequences of utf-16 code units; each code unit is represented by a 16-bit number.
...you can use named iifes (immedia
tely invoked function expressions) as shown below: var charsinbody = (function counter(elm) { if (elm.nodetype == 3) { // text_node return elm.nodevalue.length; } var count = 0; for (var i = 0, child; child = elm.childnodes[i]; i++) { count += counter(child); } return count; })(document.body); the name provided to a function expression as above is only available to the function...
Concurrency model and the event loop - JavaScript
"run-to-completion" each message is processed comple
tely before any other message is processed.
... here is an example that demonstrates this concept (settimeout does not run immedia
tely after its timer expires): const s = new date().getseconds(); settimeout(function() { // prints out "2", meaning that the callback is not called immedia
tely after 500 milliseconds.
Control flow and error handling - JavaScript
"standalone" blocks in javascript can produce comple
tely different results from what they would produce in c or java.
...if any statement within the try block (or in a function called from within the try block) throws an exception, control immedia
tely shifts to the catch block.
Indexed collections - JavaScript
the simplest way to do this is as follows: let colors = ['red', 'green', 'blue'] for (let i = 0; i < colors.length; i++) { console.log(colors[i]) } if you know that none of the elements in your array evaluate to false in a boolean context—if your array consists only of dom nodes, for example—you can use a more efficient idiom: let divs = document.ge
telementsbytagname('div') for (let i = 0, div; div = divs[i]; i++) { /* process div in some way */ } this avoids the overhead of checking the length of the array, and ensures that the div variable is reassigned to the current item each time around the loop for added convenience.
... working with array-like objects some javascript objects, such as the nodelist returned by document.ge
telementsbytagname() or the arguments object made available within the body of a function, look and behave like arrays on the surface but do not share all of their methods.
JavaScript modules - JavaScript
these are fairly trivial, but have been kept delibera
tely simple to demonstrate modules clearly.
... fortuna
tely there are a number of ways to get around this.
Numbers and dates - JavaScript
if the digits after 0x are outside the range (0123456789abcdef), the following syntaxerror is thrown: "identifier starts immedia
tely after numeric literal".
... with the "get" and "set" methods you can get and set seconds, minutes, hours, day of the month, day of the week, months, and years separa
tely.
Assertions - JavaScript
if the multiline flag is set to true, also matches immedia
tely after a line break character.
...if the multiline flag is set to true, also matches immedia
tely before a line break character.
Regular expressions - JavaScript
these flags can be used separa
tely or together in any order, and are included as part of the regular expression.
...</p> <form action="#"> <input id="phone"> <button onclick="testinfo(document.ge
telementbyid('phone'));">check</button> </form> javascript var re = /(?:\d{3}|\(\d{3}\))([-\/\.])\d{3}\1\d{4}/; function testinfo(phoneinput) { var ok = re.exec(phoneinput.value); if (!ok) { console.error(phoneinput.value + ' isn\'t a phone number with area code!'); } else { console.log('thanks, your phone number is ' + ok[0]);} } result tools regexr an online tool to learn,...
Inheritance and the prototype chain - JavaScript
making your javascript run fast is comple
tely out of the question if you dare use this in the final production code because many browsers optimize the prototype and try to guess the location of the method in the memory when calling an instance in advance, but setting the prototype dynamically disrupts all these optimizations and can even force some browsers to recompile for deoptimization your code just to make it work according to the spec...
...making your javascript run fast is comple
tely out of the question if you dare use this in the final production code because many browsers optimize the prototype and try to guess the location of the method in the memory when calling an instance in advance, but setting the prototype dynamically disrupts all these optimizations and can even force some browsers to recompile for deoptimization your code just to make it work according to the spec...
TypeError: Reduce of empty array with no initial value - JavaScript
similarly, the same issue can happen if there is a typo in a selector, or an unexpected number of elements in a list: var names = document.ge
telementsbyclassname("names"); var name_list = array.prototype.reduce.call(names, (acc, name) => acc + ", " + name); valid cases these problems can be solved in two different ways.
... var names = document.ge
telementsbyclassname("names"); var name_list1 = ""; if (names1.length >= 1) name_list1 = array.prototype.reduce.call(names, (acc, name) => acc + ", " + name); // name_list1 == "" when names is empty.
JavaScript error reference - JavaScript
these errors can be a helpful debugging aid, but the reported problem isn't always immedia
tely clear.
...use //# insteadsyntaxerror: a declaration in the head of a for-of loop can't have an initializersyntaxerror: applying the "delete" operator to an unqualified name is deprecatedsyntaxerror: for-in loop head declarations may not have initializerssyntaxerror: function statement requires a namesyntaxerror: identifier starts immedia
tely after numeric literalsyntaxerror: illegal charactersyntaxerror: invalid regular expression flag "x"syntaxerror: missing ) after argument listsyntaxerror: missing ) after conditionsyntaxerror: missing : after property idsyntaxerror: missing ; before statementsyntaxerror: missing = in const declarationsyntaxerror: missing ] after element listsyntaxerror: missing formal parametersyntaxerror: missin...
Functions - JavaScript
when functions are used only once, a common pattern is an iife (immedia
tely invoked function expression).
...ly: function multiply(x, y) { return x * y; } // there is no semicolon here a function expression of an anonymous function assigned to the variable multiply: var multiply = function(x, y) { return x * y; }; a function expression of a function named func_name assigned to the variable multiply: var multiply = function func_name(x, y) { return x * y; }; differences all do approxima
tely the same thing, with a few subtle differences: there is a distinction between the function name and the variable the function is assigned to.
Array.prototype.every() - JavaScript
if such an element is found, the every method immedia
tely returns false.
... the this value ultima
tely observable by callback is determined according to the usual rules for determining the this seen by a function.
Array.prototype.some() - JavaScript
if such an element is found, some() immedia
tely returns true.
...the this value ultima
tely observable by callback is determined according to the usual rules for determining the this seen by a function.
Error.prototype.toSource() - JavaScript
this string can be evaluated to create an (approxima
tely) equal object.
... note: be aware that the properties used by the tosource method in the creation of this string are mutable and may not accura
tely reflect the function used to create an error instance or the filename or line number where the actual error occurred.
Intl.DateTimeFormat() constructor - JavaScript
possible values include: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "
telu", "thai", "tibt".
...possible values include: "arab", "arabext", " bali", "beng", "deva", "fullwide", " gujr", "guru", "hanidec", "khmr", " knda", "laoo", "latn", "limb", "mlym", " mong", "mymr", "orya", "tamldec", "
telu", "thai", "tibt".
Intl.NumberFormat() constructor - JavaScript
gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "
telu", "thai", "tibt", "tirh", "vaii", "wara", "wcho".
...possible values include: "arab", "arabext", " bali", "beng", "deva", "fullwide", " gujr", "guru", "hanidec", "khmr", " knda", "laoo", "latn", "limb", "mlym", " mong", "mymr", "orya", "tamldec", "
telu", "thai", "tibt".
JSON.stringify() - JavaScript
all symbol-keyed properties will be comple
tely ignored, even when using the replacer function.
... issue with plain json.stringify for use as javascript historically, json was not a comple
tely strict subset of javascript.
Object.create() - JavaScript
custom and null objects a new object created from a comple
tely custom object (especially one created from the null object, which is basically a custom object with no members) can behave in unexpected ways.
... var obj = object.create({ a: 1, b: 2 }); > console.log(object.entries(obj)); // shows "[]" some non-solutions a good solution for the missing object-methods is not immedia
tely apparent.
Object.freeze() - JavaScript
> object.freeze(1) typeerror: 1 is not an object // es5 code > object.freeze(1) 1 // es2015 code an arraybufferview with elements will cause a typeerror, as they are views over memory and will defini
tely cause other possible issues: > object.freeze(new uint8array(0)) // no elements uint8array [] > object.freeze(new uint8array(1)) // has elements typeerror: cannot freeze array buffer views with elements > object.freeze(new dataview(new arraybuffer(32))) // no elements dataview {} > object.freeze(new float64array(new arraybuffer(64), 63, 0)) // no elements float64array [] > object.freeze(new ...
...float64array(new arraybuffer(64), 32, 2)) // has elements typeerror: cannot freeze array buffer views with elements note that; as the standard three properties (buf.by
telength, buf.byteoffset and buf.buffer) are read-only (as are those of an arraybuffer or sharedarraybuffer), there is no reason for attempting to freeze these properties.
Set.prototype.forEach() - JavaScript
the this value ultima
tely observable by callback is determined according to the usual rules for determining the this seen by a function.
... examples logging the contents of a set object the following code logs a line for each element in a set object: function logse
telements(value1, value2, set) { console.log('s[' + value1 + '] = ' + value2); } new set(['foo', 'bar', undefined]).foreach(logse
telements); // logs: // "s[foo] = foo" // "s[bar] = bar" // "s[undefined] = undefined" specifications specification ecmascript (ecma-262)the definition of 'set.prototype.foreach' in that specification.
SharedArrayBuffer.prototype.slice() - JavaScript
if end is omitted, slice extracts through the end of the sequence (sab.by
telength).
... examples using slice var sab = new sharedarraybuffer(1024); sab.slice(); // sharedarraybuffer { by
telength: 1024 } sab.slice(2); // sharedarraybuffer { by
telength: 1022 } sab.slice(-2); // sharedarraybuffer { by
telength: 2 } sab.slice(0, 1); // sharedarraybuffer { by
telength: 1 } specifications specification ecmascript (ecma-262)the definition of 'sharedarraybuffer.prototype.slice' in that specification.
SharedArrayBuffer - JavaScript
instance properties sharedarraybuffer.prototype.by
telength the size, in bytes, of the array.
... examples creating a new sharedarraybuffer var sab = new sharedarraybuffer(1024); slicing the sharedarraybuffer sab.slice(); // sharedarraybuffer { by
telength: 1024 } sab.slice(2); // sharedarraybuffer { by
telength: 1022 } sab.slice(-2); // sharedarraybuffer { by
telength: 2 } sab.slice(0, 1); // sharedarraybuffer { by
telength: 1 } using it in a webgl buffer const canvas = document.queryselector('canvas'); const gl = canvas.getcontext('webgl'); const buffer = gl.createbuffer(); gl.bindbuffer(gl.array_buffer, buffer); gl.bufferdata(gl.array_buf...
TypedArray.prototype.every() - JavaScript
if such an element is found, the every method immedia
tely returns false.
... the this value ultima
tely observable by callback is determined according to the usual rules for determining the this seen by a function.
TypedArray.prototype.some() - JavaScript
if such an element is found, some immedia
tely returns true.
... the this value ultima
tely observable by callback is determined according to the usual rules for determining the this seen by a function.
WebAssembly.Module() constructor - JavaScript
a webassembly.module() constructor creates a new module object containing sta
teless webassembly code that has already been compiled by the browser and can be efficiently shared with workers, and instantiated multiple times.
... syntax important: since compilation for large modules can be expensive, developers should only use the module() constructor when synchronous compilation is absolu
tely required; the asynchronous webassembly.compilestreaming() method should be used at all other times.
Function expression - JavaScript
a function expression can be used as an iife (immedia
tely invoked function expression) which runs as soon as it is defined.
...the function returns the square of its argument: var x = function(y) { return y * y; }; using a function as a callback more commonly it is used as a callback: button.addeventlistener('click', function(event) { console.log('button is clicked!') }) using an immedia
tely executed function expression an anonymous function is created and called: (function() { console.log('code runs!') })(); specifications specification ecmascript (ecma-262)the definition of 'function definitions' in that specification.
yield - JavaScript
the next time next() is called, execution resumes with the statement immedia
tely after the yield.
... unfortuna
tely, next() is asymmetric, but that can’t be helped: it always sends a value to the currently suspended yield, but returns the operand of the following yield.
Transitioning to strict mode - JavaScript
the only legitimate use case would be to reuse a function as in: // example taken from vanillajs: http://vanilla-js.com/ var s = document.ge
telementbyid('thing').style; s.opacity = 1; (function() { if ((s.opacity-=.1) < 0) s.display = 'none'; else settimeout(arguments.callee, 40); })(); which can be rewritten as: 'use strict'; var s = document.ge
telementbyid('thing').style; s.opacity = 1; (function fadeout() { // name the function if((s.opacity-=.1) < 0) s.display = 'none'; else settimeout(fadeout, 40); // use t...
...fortuna
tely, this careful review can be done gradually down the function granularity.
OpenSearch description format
note: for icons loaded remo
tely (that is, from https:// uris as opposed to data: uris), firefox will reject icons larger than 10 kilobytes.
... remo
tely fetched favicons must not be larger than 10kb (see bug 361923).
Populating the page: how browsers work - Web Performance
tcp's three way handshaking technique is often referred to as "syn-syn-ack"—or more accura
tely syn, syn-ack, ack—because there are three messages transmitted by tcp to negotiate and start a tcp session between two computers.
... in our example above, the request is defini
tely less than 14kb, but the linked resources aren't requested until the browser encounters the links during parsing, described below.
Progressive web app structure - Progressive web apps (PWAs)
that way, the next time someone visits the app from the device, the ui loads from the cache immedia
tely and any new content is requested from the server (if it isn’t available in the cache already).
...var entry = template.replace(/pos/g,(i+1)) .replace(/slug/g,games[i].slug) .replace(/name/g,games[i].name) .replace(/author/g,games[i].author) .replace(/twitter/g,games[i].twitter) .replace(/website/g,games[i].website) .replace(/github/g,games[i].github); entry = entry.replace('<a href=\'http:///\'></a>','-'); content += entry; }; document.ge
telementbyid('content').innerhtml = content; next, it registers a service worker: if('serviceworker' in navigator) { navigator.serviceworker.register('/pwa-examples/js13kpwa/sw.js'); }; the next code block requests permission for notifications when a button is clicked: var button = document.ge
telementbyid("notifications"); button.addeventlistener('click', function(e) { notification.reques...
Progressive loading - Progressive web apps (PWAs)
this is all about deferring loading of as many resources as possible (html, css, javascript), and only loading those immedia
tely that are really needed for the very first experience.
...we can also split css files and add media types to them: <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="print.css" media="print"> this will
tell the browser to load them only when the condition is met.
Media - Progressive web apps (PWAs)
for double-sided printing, you can specify the margins separa
tely for @page:left and @page:right.
...keep in mind that you can't comple
tely control the printed format.
Applying SVG effects to HTML content - SVG: Scalable Vector Graphics
you can make changes to the svg in real time and see them immedia
tely affect the rendering of the html.
... for example, you can resize the circle in the clip path established above: function toggleradius() { var circle = document.ge
telementbyid("circle"); circle.r.baseval.value = 0.40 - circle.r.baseval.value; } example: filtering this demonstrates applying a filter to html content using svg.
SVG 1.1 Support in Firefox - SVG: Scalable Vector Graphics
doesn't comple
tely follow <svg:use> cascading rules (bug 265894).
... various presentation attributes don't work (alignment-baseline, baseline-shift, dominant-baseline, kerning, letter-spacing, word-spacing, writing-mode, glyph-orientation-horizontal, glyph-orientation-vertical) recently implemented presentation attributes: direction, unicode-bidi, font-variant, text-decoration svgtex
telement recently imlemented bindings: selectsubstring recently implemented attributes: textlength, lengthadjust tspan implemented.
Clipping and masking - SVG: Scalable Vector Graphics
color, opacity and such have no effect as long as they don't let parts vanish comple
tely.
...for the fill and stroke there are two separate attributes, fill-opacity and stroke-opacity, that control each of those property opacities separa
tely.
Fills and Strokes - SVG: Scalable Vector Graphics
<rect x="10" y="10" width="100" height="100" stroke="blue" fill="purple" fill-opacity="0.5" stroke-opacity="0.8"/> in addition, you can specify the opacity of either the fill or stroke separa
tely in svg.
...but for compatibility with other viewers, it's often best to specify the fill/stroke opacity separa
tely.
Gradients in SVG - SVG: Scalable Vector Graphics
these nodes
tell the gradient what color it should be at certain positions by specifying an offset attribute for the position, and a stop-color attribute.
...for instance, this one
tells the gradient to start at the color red, change to transparent-black in the middle, and end at the color blue.
SVG In HTML Introduction - SVG: Scalable Vector Graphics
source here is the source to the example: <html> <head> <title>xtech svg demo</title> <style> stop.begin { stop-color:yellow; } stop.end { stop-color:green; } body.invalid stop.end { stop-color:red; } #err { display:none; } body.invalid #err { display:inline; } </style> <script> function signalerror() { document.ge
telementbyid('body').setattribute("class", "invalid"); } </script> </head> <body id="body" style="position:absolute; z-index:0; border:1px solid black; left:5%; top:5%; width:90%; height:90%;"> <form> <fieldset> <legend>html form</legend> <p><label>enter something:</label> <input type="text"> <span id="err">incorrect value!</span></p> <p><input type="button" value="activate!
...ach has the following points in its favor: we have taken a regular html form that could have been part of an existing web site, and added an attractive, interactive background the approach is backwards compatible to browsers that do not support svg; simply, no background appears in them it's very simple and performs very well the picture dynamically sizes itself to the required size in an in
telligent way we can have declarative style rules applying to both html and svg the same script manipulates both html and svg the document is entirely standards-based to add a linked image with dom methods to an embedded svg element, one has to use setattributens to set href.
Texts - SVG: Scalable Vector Graphics
« previousnext » when talking about text in svg we have to differentiate two almost comple
tely separate topics.
...the latter may be described in a later section of the tutorial, while we will focus comple
tely on the first part: bringing text into an svg image.
Transport Layer Security - Web security
the transport layer security (tls) protocol is the standard for enabling two networked applications or devices to exchange information priva
tely and robustly.
...clients that reconnect to the server can send requests immedia
tely, eliminating the latency of the tls handshake entirely.
Advanced Example - XSLT: Extensible Stylesheet Language Transformations
// importnode is used to clone the nodes we want to process via xslt - true makes it do a deep clone var mynode = document.ge
telementbyid("example"); var clonednode = xmlref.importnode(mynode, true); // after cloning, we append xmlref.appendchild(clonednode); // set the sorting parameter in the xsl file var sortval = xsltprocessor.getparameter(null, "myorder"); if (sortval == "" || sortval == "descending") xsltprocessor.setparameter(null, "myorder", "ascending"); else xsltprocessor.setparameter(nul...
...l, "myorder", "descending"); // initiate the transformation var fragment = xsltprocessor.transformtofragment(xmlref, document); // clear the contents document.ge
telementbyid("example").innerhtml = ""; mydom = fragment; // add the new content from the transformation document.ge
telementbyid("example").appendchild(fragment) } // xsl stylesheet: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="html" indent="yes" /> <xsl:param name="myorder" /> <xsl:template match="/"> <xsl:apply-templates select="/div//div"> <xsl:sort select="." data-type="number" order="{$myorder}" /> </xsl:apply-template...
Listening for Load and Unload - Archive of obsolete content
if your add-on exports a function called main(), that function will be called immedia
tely after the overall main.js is evaluated, and after all top-level require() statements have run (so generally after all dependent modules have been loaded).
Open a Web Page - Archive of obsolete content
to open a new web page, you can use the tabs module: var tabs = require("sdk/tabs"); tabs.open("http://www.example.com"); this function is asynchronous, so you don't immedia
tely get back a tab object which you can examine.
Unit Testing - Archive of obsolete content
unfortuna
tely these functions are attached to the window object: since this object is not available in your main add-on code, atob() and btoa() aren't available either.
Localization - Archive of obsolete content
for example, here's a "package.json" defining a german localization for title and description: { "locales": { "de": { "title": "monstergenerator", "description": "ers
telle dein eigenes monster" } }, "name": "monster-builder", "license": "mpl 2.0", "author": "me", "version": "0.1", "title": "monster builder", "id": "monster-builder@me.org", "description": "build your own monster" } using localized strings in preferences by including a "preferences" structure in your add-on's "package.json" file, you can define preferences...
Downloading Files - Archive of obsolete content
var privacy = privatebrowsingutils.privacycontextfromwindow(aurlsourcewindow); var progresselement = document.ge
telementbyid("progress_element"); persist.progresslistener = { onprogresschange: function(awebprogress, arequest, acurselfprogress, amaxselfprogress, acurtotalprogress, amaxtotalprogress) { var percentcomplete = math.round((acurtotalprogress / amaxtotalprogress) * 100); progresselement.textcontent = percentcomplete +"%"; }, onstatechange: function(awebprogress, arequest, astateflags, as...
Forms related code snippets - Archive of obsolete content
function ondayclick () { const othiscal = ainstances[this.id.replace(rbgnandend, "")]; othiscal.target.value = (this.innerhtml / 100).tofixed(2).substr(-2) + "\/" + (othiscal.current.getmonth() + 1) + "\/" + othiscal.current.getfullyear(); othiscal.container.parentnode.removechild(othiscal.container); return false; } function buildcalendars () { const afields = document.ge
telementsbyclassname(sdpclass), nlen = afields.length; for (var nitem = 0; nitem < nlen; new datepicker(afields[nitem++])); } const /* customizable by user */ sprefs = "zdp"; sdpclass = "date-picker", smonthsnames = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"], sdays = ["m", "t", "w", "t", "f", "s", "s"], bzeroismonday = true, ...
IsDefaultNamespace - Archive of obsolete content
} } } if (node.parentnode) { // entityreferences may have to be skipped to get to it return isdefaultnamespace(node.parentnode, namespaceuri); } else { return false; // unknown; } case 9: // document_node return isdefaultnamespace(node.documen
telement, namespaceuri); case 6: // entity_node case 12: // notation_node case 10: // document_type_node case 11: // document_fragment_node return false; // unknown case 2: // attribute_node: if (node.ownerelement ) { return isdefaultnamespace(node.ownerelement , namespaceuri); } else { ...
JS XPCOM - Archive of obsolete content
accessing xpcom components from javascript xpcom objects are either created as new instances (each creation gives you a comple
tely new com object) or as services (each access gives you the same com object, often called a singleton).
LookupNamespaceURI - Archive of obsolete content
} } if (node.parentnode && node.parentnode.nodetype !== 9) { // entityreferences may have to be skipped to get to it return lookupnamespaceurihelper(node.parentnode, prefix); } return null; case 9: // document_node return lookupnamespaceurihelper(node.documen
telement, prefix); case 6: // entity_node case 12: // notation_node case 10: // document_type_node case 11: // document_fragment_node return null; // unknown case 2: // attribute_node if (node.ownerelement) { return lookupnamespaceurihelper(node.ownerelement, prefix); } ...
LookupPrefix - Archive of obsolete content
ext/html') { // shouldn't use this in text/html for mozilla as will return null return node.lookupprefix(namespaceuri); } if (namespaceuri === null || namespaceuri === '') { return null; } switch (node.nodetype) { case 1: // node.element_node return _lookupnamespaceprefix(namespaceuri, node); case 9: // node.document_node return _lookupnamespaceprefix(namespaceuri, node.documen
telement); case 6: // node.entity_node case 12: // node.notation_node case 11: // node.document_fragment_node case 10: // node.document_type_node return null; // type is unknown case 2: // node.attribute_node if (node.ownerelement) { return _lookupnamespaceprefix(namespaceuri, node.ownerelement); } return null; default: if (node.parentnode) { // entityreferences ma...
On page load - Archive of obsolete content
pt to your overlay (see "attaching a script to an overlay") that adds a load event listener to appcontent element (browsers) or messagepane (mail): window.addeventlistener("load", function load(event){ window.removeeventlistener("load", load, false); //remove listener, no longer needed myextension.init(); },false); var myextension = { init: function() { var appcontent = document.ge
telementbyid("appcontent"); // browser if(appcontent){ appcontent.addeventlistener("domcontentloaded", myextension.onpageload, true); } var messagepane = document.ge
telementbyid("messagepane"); // mail if(messagepane){ messagepane.addeventlistener("load", function(event) { myextension.onpageload(event); }, true); } }, onpageload: function(aevent) { var doc =...
arrowscrollbox - Archive of obsolete content
inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
assign - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
bbox - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
binding - Archive of obsolete content
es, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
bindings - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
box - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
broadcaster - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
broadcasterset - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
browser - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
button - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
caption - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
checkbox - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
colorpicker - Archive of obsolete content
value property gets and sets color attribute methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
column - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
columns - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
command - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
commandset - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
conditions - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
content - Archive of obsolete content
métodos inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
deck - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
dialogheader - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
dropmarker - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
grid - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
grippy - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
groupbox - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
hbox - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
keyset - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
label - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
listcell - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
listcol - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
listcols - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
listhead - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
listheader - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
listitem - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
member - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
menu - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
menubar - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
menuseparator - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
notification - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
observes - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
page - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
param - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
popupset - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
preferences - Archive of obsolete content
inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
query - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
queryset - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
radio - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
resizer - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
richlistbox - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
richlistitem - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
row - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
rows - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
rule - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
scale - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
script - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
scrollbar - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
scrollbox - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
scrollcorner - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
separator - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
spacer - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
spinbuttons - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
stack - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
statusbar - Archive of obsolete content
es, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
<statusbarpanel> - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
stringbundle - Archive of obsolete content
inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
stringbundleset - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
tabbox - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
tabbrowser - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
tabpanel - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
tabpanels - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
tabs - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
template - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
textbox - Archive of obsolete content
inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
textnode - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
titlebar - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbar - Archive of obsolete content
inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbargrippy - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbaritem - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbarpalette - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbarseparator - Archive of obsolete content
es, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbarset - Archive of obsolete content
es, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbarspacer - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbarspring - Archive of obsolete content
es, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
toolbox - Archive of obsolete content
methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), removeattributeno...
treecell - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
treechildren - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
treecol - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
treecols - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
treeitem - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
treerow - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
treeseparator - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
triple - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
vbox - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
where - Archive of obsolete content
, ordinal, orient, , pack, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
wizardpage - Archive of obsolete content
, , persist, , , , ref, resource, , , , , statustext, style, ,, tooltip, tooltiptext, top, width methods inherited methods addeventlistener(), appendchild(), blur, click, clonenode(), comparedocumentposition, dispatchevent(), docommand, focus, getattribute(), getattributenode(), getattributenodens(), getattributens(), getboundingclientrect(), getclientrects(), ge
telementsbyattribute, ge
telementsbyattributens, ge
telementsbyclassname(), ge
telementsbytagname(), ge
telementsbytagnamens(), getfeature, getuserdata, hasattribute(), hasattributens(), hasattributes(), haschildnodes(), insertbefore(), isdefaultnamespace(), isequalnode, issamenode, issupported(), lookupnamespaceuri, lookupprefix, normalize(), queryselector(), queryselectorall(), removeattribute(), remov...
Building XULRunner with Python - Archive of obsolete content
for example def onload(): btntest = document.ge
telementbyid("btntest") btntest.addeventlistener('command', ontest, false) def ontest(): window.alert('button activated') window.addeventlistener('load', onload, false) one possible gotcha is that the default python path used to find modules that areimported explicitly includes the xulrunner executable directory and the directory that is current when xulrunner launches.
Add New Tab
var aurl = "chrome://myext/mytab.xul"; let tabmail = getmail3pane().document.ge
telementbyid("tabmail"); tabmail.opentab("chrometab", { chromepage: aurl }); ...
Detect Opening Folder
to do this you need to capture the select event of the folder [[xul:tree|tree]] whose id is (conveniently) foldertree like so: window.document.ge
telementbyid('foldertree').addeventlistener("select", testcolumns, false); ...
Toolkit version format
a few examples of valid version parts: 0 (as in 1.0): <number-a>=0 5a (as in 1.5a): <number-a>=5, <string-b>=a 5pre4 (as in 3.5pre4): <number-a>=5, <string-b>=pre, <number-c>=4 * (as in 1.0.*): <string-b>=* a few special parsing rules are applied for backwards compatibility and readability: if the version part is a single asterisk, it is interpreted as an infini
tely-large number: 1.5.0.* is the same as 1.5.0.(infinity) if string-b is a plus sign, number-a is incremented to be compatible with the firefox 1.0.x version format: 1.0+ is the same as 1.1pre the rationale behind splitting a version part into a sequence of strings and numbers is that when comparing version parts, the numeric parts are compared as numbers, e.g.
Using popup notifications
components.utils.import('resource://gre/modules/popupnotifications.jsm'); var notify = new popupnotifications(gbrowser, document.ge
telementbyid("notification-popup"), document.ge
telementbyid("notification-popup-box")); var notification = notify.show( // browser gbrowser.selectedbrowser, // popup id "pdes-popup", // message "hi, there!, i'm gonna show you something today!!", // anchor id null, // main action { label: "click here", accesskey: "d", callback: function() { // you can call you...
Virtualenv
> ls tmp/bin/ activate activate.fish easy_install pip python activate.csh activate_this.py easy_install-2.7 pip-2.7 using this python binary, or these scripts (which point to this python binary), you will correctly install python packages in the lib/python2.x/site-packages directory and they will be appropria
tely added to your import path (sys.path) via lib/python2.x/site.py.
Zombie compartments
this page
tells you how to detect and avoid zombie compartments, which are a particular kind of memory leak.
Using COM from js-ctypes
0x9e', '0xe3', '0x00', '0xc0', '0x4f', '0x79', '0x73', '0x96']); let iid_ispvoice = iidfromarr(['0x6c44df74', '0x72b9', '0x4992', '0xa1', '0xec', '0xef', '0x99', '0x6e', '0x04', '0x22', '0xd4']); let spf_default = 0; function main() { let spvoice; let spvoiceptr; try { // msdn docs
tell us ot use coinitex instead of coinit, and default is 0 // which is coinit_multithreaded but it wouldnt work so i used // coinit_apartmentthreaded and it worked checkhresult would throw a bad // hresult of rpc_e_changed_mode which is 0x80010106 which is // -2147417850.
Standard OS Libraries
although jni is done comple
tely through js-ctypes, a jsm was created to abstract away the js-ctypes so developers can focus on the jni aspect.
Using js-ctypes
r('we just called the equivalent of the "standardalert carbon function" for 64bit osx from javascript!') }; var rez = cfusernotificationdisplaynotice(0, kcfusernotificationcautionalertlevel, null, null, null, mycfstrs.head, mycfstrs.body, null); console.info('rez:', rez, rez.tostring(), uneval(rez)); // cfusernotificationdisplaynotice does not block till user clicks dialog, it will return immedia
tely if (rez.tostring() == '0') { console.log('notification was succesfully shown!!'); } else { console.error('failed to show notification...
ctypes
so we will figure that out and create the structure appropria
tely.
Initialization and Destruction - Plugins
instance destruction: the plug-in instance is deleted when the user leaves the instance page or closes the instance window; the browser calls the function npp_destroy to
tell the plug-in that the instance is being deleted.
Plug-in Development Overview - Plugins
consider the following example, where a media player plug-in can be controlled with an advancetonextsong() method called inside the script element: <object id="myplugin" type="audio/wav" data="music.wav"> </object> <script type="application/javascript"> var theplugin = document.ge
telementbyid('myplugin'); if (theplugin && theplugin.advancetonextsong) theplugin.advancetonextsong(); else alert("plugin not installed correctly"); </script> in the past, liveconnect and later xpconnect were used to make plug-ins scriptable.
Gecko Plugin API Reference - Plugins
dowed plug-ins mac os windows unix event handling for windowed plug-ins windowless plug-ins specifying that a plug-in is windowless invalidating the drawing area forcing a paint message making a plug-in opaque making a plug-in transparent creating pop-up menus and dialog boxes event handling for windowless plug-ins streams receiving a stream
telling the plug-in when a stream is created
telling the plug-in when a stream is deleted finding out how much data the plug-in can accept writing the stream to the plug-in sending the stream in random-access mode sending the stream in file mode sending a stream creating a stream pushing data into the stream deleting the stream example of sending a stream urls getting urls getti...
CanvasCaptureMediaStreamTrack.requestFrame() - Web APIs
example // find the canvas element to capture var canvaselt = document.ge
telementsbytagname("canvas")[0]; // get the stream var stream = canvaselt.capturestream(25); // 25 fps // send the current state of the canvas as a frame to the stream stream.getvideotracks()[0].requestframe(); specifications specification status comment media capture from dom elementsthe definition of 'canvascapturemediastream.requestframe()' in that specification.
CanvasGradient.addColorStop() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let gradient = ctx.crea
telineargradient(0, 0, 200, 0); gradient.addcolorstop(0, 'green'); gradient.addcolorstop(.7, 'white'); gradient.addcolorstop(1, 'pink'); ctx.fillstyle = gradient; ctx.fillrect(10, 10, 200, 100); result specifications specification status comment html living standardthe definition of 'can...
CanvasGradient - Web APIs
it is returned by the methods canvasrenderingcontext2d.crea
telineargradient() or canvasrenderingcontext2d.createradialgradient().
CanvasRenderingContext2D.beginPath() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // first path ctx.beginpath(); ctx.strokestyle = 'blue'; ctx.moveto(20, 20); ctx.lineto(200, 20); ctx.stroke(); // second path ctx.beginpath(); ctx.strokestyle = 'green'; ctx.moveto(20, 20); ctx.lineto(120, 120); ctx.stroke(); result specifications specification status comment html living standardthe definiti...
CanvasRenderingContext2D.canvas - Web APIs
you can get a reference to the canvas element within the canvasrenderingcontext2d by using the canvas property: var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.canvas // htmlcanvaselement specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.canvas' in that specification.
CanvasRenderingContext2D.clearHitRegions() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // set some hit regions ctx.addhitregion({id: 'eyes'}); ctx.addhitregion({id: 'nose'}); ctx.addhitregion({id: 'mouth'}); // remove them altogether from the canvas ctx.clearhitregions(); specifications canvas hit regions have been removed from the whatwg living standard, although discussions about future standardization are ongoing.
CanvasRenderingContext2D.createPattern() - Web APIs
the original image looks like this: html <canvas id="canvas" width="300" height="300"></canvas> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); var img = new image(); img.src = 'https://udn.realityripple.com/samples/04/aaeaf9aac4.png'; img.onload = function() { var pattern = ctx.createpattern(img, 'repeat'); ctx.fillstyle = pattern; ctx.fillrect(0, 0, 300, 300); }; creating a pattern from a canvas in this example we create a pattern from the contents of an offscreen canva...
CanvasRenderingContext2D.createRadialGradient() - Web APIs
html <canvas id="canvas" width="200" height="200"></canvas> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); // create a radial gradient // the inner circle is at x=110, y=90, with radius=30 // the outer circle is at x=100, y=100, with radius=70 var gradient = ctx.createradialgradient(110,90,30, 100,100,70); // add three color stops gradient.addcolorstop(0, 'pink'); gradient.addcolorstop(.9, 'white'); gradient.addcolorstop(1, 'green'); // set the...
CanvasRenderingContext2D.currentTransform - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let matrix = ctx.currenttransform; matrix.a = 1; matrix.b = 1; matrix.c = 0; matrix.d = 1; matrix.e = 0; matrix.f = 0; ctx.currenttransform = matrix; ctx.fillrect(0, 0, 100, 100); result ...
CanvasRenderingContext2D.direction - Web APIs
html <canvas id="canvas"></canvas> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.font = '48px serif'; ctx.filltext('hi!', 150, 50); ctx.direction = 'rtl'; ctx.filltext('hi!', 150, 130); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.direction' in that specification.
CanvasRenderingContext2D.drawFocusIfNeeded() - Web APIs
html <canvas id="canvas"> <button id="button1">continue</button> <button id="button2">quit</button> </canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const button1 = document.ge
telementbyid('button1'); const button2 = document.ge
telementbyid('button2'); document.addeventlistener('focus', redraw, true); document.addeventlistener('blur', redraw, true); canvas.addeventlistener('click', handleclick, false); redraw(); function redraw() { ctx.clearrect(0, 0, canvas.width, canvas.height); ...
CanvasRenderingContext2D.font - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = 'bold 48px serif'; ctx.stroketext('hello world', 50, 100); result loading fonts with the css font loading api with the help of the fontface api, you can explicitly load fonts before using them in a canvas.
CanvasRenderingContext2D.getImageData() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.rect(10, 10, 100, 100); ctx.fill(); let imagedata = ctx.getimagedata(60, 60, 200, 100); ctx.putimagedata(imagedata, 150, 10); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.getimagedata' in that specification.
CanvasRenderingContext2D.globalCompositeOperation - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.globalcompositeoperation = 'xor'; ctx.fillstyle = 'blue'; ctx.fillrect(10, 10, 100, 100); ctx.fillstyle = 'red'; ctx.fillrect(50, 50, 100, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.globalcompositeoperation' in that specificati...
CanvasRenderingContext2D.imageSmoothingEnabled - Web APIs
html <canvas id="canvas" width="460" height="210"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.font = '16px sans-serif'; ctx.textalign = 'center'; const img = new image(); img.src = 'https://interactive-examples.mdn.mozilla.net/media/examples/star.png'; img.onload = function() { const w = img.width, h = img.height; ctx.filltext('source', w * .5, 20); ctx.drawimage(img, 0, 24, w, h); ctx.filltext('smoothing = t...
CanvasRenderingContext2D.imageSmoothingQuality - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let img = new image(); img.src = 'https://mdn.mozillademos.org/files/222/canvas_createpattern.png'; img.onload = function() { ctx.imagesmoothingquality = 'low'; ctx.drawimage(img, 0, 0, 300, 150); }; result specifications specification status comment html living standardthe definition of 'imagesmoothingqua...
CanvasRenderingContext2D.lineWidth - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.linewidth = 15; ctx.beginpath(); ctx.moveto(20, 20); ctx.lineto(130, 130); ctx.rect(40, 40, 70, 70); ctx.stroke(); result more examples for more examples and explanation about this property, see applying styles and color in the canvas tutorial.
CanvasRenderingContext2D.measureText() - Web APIs
you can get a textmetrics object using the following code: const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); let text = ctx.measuretext('hello world'); console.log(text.width); // 56; specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.measuretext' in that specification.
CanvasRenderingContext2D.miterLimit - Web APIs
ayable code <canvas id="canvas" width="400" height="200" class="playable-canvas"></canvas> <div class="playable-buttons"> <input id="edit" type="button" value="edit" /> <input id="reset" type="button" value="reset" /> </div> <textarea id="code" class="playable-code"> ctx.beginpath(); ctx.moveto(0,0); ctx.linewidth = 15; ctx.lineto(100, 100); ctx.stroke();</textarea> var canvas = document.ge
telementbyid("canvas"); var ctx = canvas.getcontext("2d"); var textarea = document.ge
telementbyid("code"); var reset = document.ge
telementbyid("reset"); var edit = document.ge
telementbyid("edit"); var code = textarea.value; function drawcanvas() { ctx.clearrect(0, 0, canvas.width, canvas.height); eval(textarea.value); } reset.addeventlistener("click", function() { textarea.value = code; dra...
CanvasRenderingContext2D.moveTo() - Web APIs
var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(50, 50); // begin first sub-path ctx.lineto(200, 50); ctx.moveto(50, 90); // begin second sub-path ctx.lineto(280, 120); ctx.stroke(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.moveto' in that specification.
CanvasRenderingContext2D.putImageData() - Web APIs
html <canvas id="canvas"></canvas> javascript var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); function putimagedata(ctx, imagedata, dx, dy, dirtyx, dirtyy, dirtywidth, dirtyheight) { var data = imagedata.data; var height = imagedata.height; var width = imagedata.width; dirtyx = dirtyx || 0; dirtyy = dirtyy || 0; dirtywidth = dirtywidth !== undefined?
CanvasRenderingContext2D.rect() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.rect(10, 20, 150, 100); ctx.fill(); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.rect' in that specification.
CanvasRenderingContext2D.removeHitRegion() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // set a hit region ctx.addhitregion({id: 'eyes'}); // remove it from the canvas ctx.removehitregion('eyes'); specifications canvas hit regions have been removed from the whatwg living standard, although discussions about future standardization are ongoing.
CanvasRenderingContext2D.restore() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // save the default state ctx.save(); ctx.fillstyle = 'green'; ctx.fillrect(10, 10, 100, 100); // restore the default state ctx.restore(); ctx.fillrect(150, 40, 100, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.restore' in that spec...
CanvasRenderingContext2D.save() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // save the default state ctx.save(); ctx.fillstyle = 'green'; ctx.fillrect(10, 10, 100, 100); // restore the default state ctx.restore(); ctx.fillrect(150, 40, 100, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.save' in that specifi...
CanvasRenderingContext2D.setTransform() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.settransform(1, .2, .8, 1, 0, 0); ctx.fillrect(0, 0, 100, 100); result retrieving and passing a dommatrix object in the following example, we have two <canvas> elements.
CanvasRenderingContext2D.shadowBlur - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // shadow ctx.shadowcolor = 'red'; ctx.shadowblur = 15; // rectangle ctx.fillstyle = 'blue'; ctx.fillrect(20, 20, 150, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.shadowblur' in that specification.
CanvasRenderingContext2D.shadowOffsetX - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // shadow ctx.shadowcolor = 'red'; ctx.shadowoffsetx = 25; ctx.shadowblur = 10; // rectangle ctx.fillstyle = 'blue'; ctx.fillrect(20, 20, 150, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.shadowoffsetx' in that specification.
CanvasRenderingContext2D.shadowOffsetY - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // shadow ctx.shadowcolor = 'red'; ctx.shadowoffsety = 25; ctx.shadowblur = 10; // rectangle ctx.fillstyle = 'blue'; ctx.fillrect(20, 20, 150, 80); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.shadowoffsety' in that specification.
CanvasRenderingContext2D.textBaseline - Web APIs
html <canvas id="canvas" width="550" height="500"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); const baselines = ['top', 'hanging', 'middle', 'alphabetic', 'ideographic', 'bottom']; ctx.font = '36px serif'; ctx.strokestyle = 'red'; baselines.foreach(function (baseline, index) { ctx.textbaseline = baseline; const y = 75 + index * 75; ctx.beginpath(); ctx.moveto(0, y + 0.5); ctx.lineto(550, y + 0.5); ctx.stroke(); ctx.f...
CanvasRenderingContext2D.transform() - Web APIs
html <canvas id="canvas"></canvas> javascript const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); ctx.transform(1, .2, .8, 1, 0, 0); ctx.fillrect(0, 0, 100, 100); result specifications specification status comment html living standardthe definition of 'canvasrenderingcontext2d.transform' in that specification.
CanvasRenderingContext2D.translate() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // moved square ctx.translate(110, 30); ctx.fillstyle = 'red'; ctx.fillrect(0, 0, 80, 80); // reset current transformation matrix to the identity matrix ctx.settransform(1, 0, 0, 1, 0, 0); // unmoved square ctx.fillstyle = 'gray'; ctx.fillrect(0, 0, 80, 80); result the moved square is red, and the unmoved square is gray.
Compositing example - Web APIs
tyle = "#f00"; ctx.fillrect(0,0,30,30) ctx.fill(); }; var colorsphere = function(element) { var ctx = canvas1.getcontext("2d"); var width = 360; var halfwidth = width / 2; var rotate = (1 / 360) * math.pi * 2; // per degree var offset = 0; // scrollbar offset var oleft = -20; var otop = -20; for (var n = 0; n <= 359; n ++) { var gradient = ctx.crea
telineargradient(oleft + halfwidth, otop, oleft + halfwidth, otop + halfwidth); var color = color.hsv_rgb({ h: (n + 300) % 360, s: 100, v: 100 }); gradient.addcolorstop(0, "rgba(0,0,0,0)"); gradient.addcolorstop(0.7, "rgba("+color.r+","+color.g+","+color.b+",1)"); gradient.addcolorstop(1, "rgba(255,255,255,1)"); ctx.beginpath(); ctx.moveto(oleft + halfw...
Compositing and clipping - Web APIs
function draw() { var ctx = document.ge
telementbyid('canvas').getcontext('2d'); ctx.fillrect(0, 0, 150, 150); ctx.translate(75, 75); // create a circular clipping path ctx.beginpath(); ctx.arc(0, 0, 60, 0, math.pi * 2, true); ctx.clip(); // draw background var lingrad = ctx.crea
telineargradient(0, -75, 0, 75); lingrad.addcolorstop(0, '#232256'); lingrad.addcolorstop(1, '#143778'); ctx.fillstyle = lingrad; ctx.fi...
Hit regions and accessibility - Web APIs
<canvas id="canvas"></canvas> <script> var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.arc(70, 80, 10, 0, 2 * math.pi, false); ctx.fill(); ctx.addhitregion({id: 'circle'}); canvas.addeventlistener('mousemove', function(event) { if (event.region) { alert('hit region: ' + event.region); } }); </script> the addhitregion() method also takes a control option to route events to an element (that is a de...
Using channel messaging - Web APIs
var input = document.ge
telementbyid('message-input'); var output = document.ge
telementbyid('message-output'); var button = document.queryselector('button'); var iframe = document.queryselector('iframe'); var channel = new messagechannel(); var port1 = channel.port1; // wait for the iframe to load iframe.addeventlistener("load", onload); function onload() { // listen for button clicks button.addeventlistener('click',...
ChildNode.remove() - Web APIs
syntax node.remove(); example using remove() <div id="div-01">here is div-01</div> <div id="div-02">here is div-02</div> <div id="div-03">here is div-03</div> var el = document.ge
telementbyid('div-02'); el.remove(); // removes the div with the 'div-02' id childnode.remove() is unscopable the remove() method is not scoped into the with statement.
Clipboard.readText() - Web APIs
navigator.clipboard.readtext().then( cliptext => document.ge
telementbyid("outbox").innertext = cliptext); specifications specification status comment clipboard api and eventsthe definition of 'readtext()' in that specification.
CustomElementRegistry.get() - Web APIs
examples customelements.define('my-paragraph', class extends htmlelement { constructor() { super(); let template = document.ge
telementbyid('my-paragraph'); let templatecontent = template.content; const shadowroot = this.attachshadow({mode: 'open'}) .appendchild(templatecontent.clonenode(true)); } }) // return a reference to the my-paragraph constructor let ctor = customelements.get('my-paragraph'); specifications specification status comment html living standardthe definiti...
DOMImplementation.createDocument() - Web APIs
example var doc = document.implementation.createdocument ('http://www.w3.org/1999/xhtml', 'html', null); var body = document.createelementns('http://www.w3.org/1999/xhtml', 'body'); body.setattribute('id', 'abc'); doc.documen
telement.appendchild(body); alert(doc.ge
telementbyid('abc')); // [object htmlbodyelement] specifications specification status comment domthe definition of 'domimplementation.createdocument' in that specification.
DOMMatrixReadOnly.flipX() - Web APIs
const flipped = document.ge
telementbyid('flipped'); const matrix = new dommatrixreadonly(); const flippedmatrix = matrix.flipx(); flipped.setattribute('transform', flippedmatrix.tostring()); screenshotlive sample specifications specification status comment geometry interfaces module level 1the definition of 'dommatrixreadonly.flipx()' in that specification.
DOMParser - Web APIs
s null on unsupported types if ((new domparser()).parsefromstring("", "text/html")) { // text/html parsing is natively supported return; } } catch (ex) {} proto.parsefromstring = function(markup, type) { if (/^\s*text\/html\s*(?:;|$)/i.test(type)) { var doc = document.implementation.createhtmldocument(""); if (markup.tolowercase().indexof('<!doctype') > -1) { doc.documen
telement.innerhtml = markup; } else { doc.body.innerhtml = markup; } return doc; } else { return nativeparse.apply(this, arguments); } }; }(domparser)); specifications specification status comment html living standardthe definition of 'dom parsing' in that specification.
DOMTokenList.remove() - Web APIs
the order you supply the tokens doesn't have to match the order they appear in the list: let span2 = document.ge
telementsbytagname("span")[0] let classes2 = span.classlist; classes2.remove("c", "b"); span2.textcontent = classes; specifications specification status comment domthe definition of 'remove()' in that specification.
DOMTokenList.supports() - Web APIs
example let iframe = document.ge
telementbyid('display'); if (iframe.sandbox.supports('an-upcoming-feature')) { // support code for mystery future feature } else { // fallback code } if (iframe.sandbox.supports('allow-scripts')) { // instruct frame to run javascript // // (note: this feature is well-supported; this is just an example!) // } specifications specification status comment crede...
DOMTokenList - Web APIs
such a set is returned by element.classlist, htmllinkelement.rellist, htmlanchorelement.rellist, htmlareaelement.rellist, htmliframeelement.sandbox, or htmloutpu
telement.htmlfor.
DataTransfer.dropEffect - Web APIs
"text", ev.target.id); ev.datatransfer.effectallowed = "move"; } function drop_handler(ev) { console.log("drop: dropeffect = " + ev.datatransfer.dropeffect + " ; effectallowed = " + ev.datatransfer.effectallowed); ev.preventdefault(); // get the id of the target and add the moved element to the target's dom var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragover_handler(ev) { console.log("dragover: dropeffect = " + ev.datatransfer.dropeffect + " ; effectallowed = " + ev.datatransfer.effectallowed); ev.preventdefault(); // set the dropeffect to move ev.datatransfer.dropeffect = "move" } specifications specification status comment html living standardthe definition of 'dropeffect' i...
DataTransfer.effectAllowed - Web APIs
etdata("text", ev.target.id); ev.datatransfer.effectallowed = "move"; } function drop_handler(ev) { console.log("drop: dropeffect = " + ev.datatransfer.dropeffect + " ; effectallowed = " + ev.datatransfer.effectallowed); ev.preventdefault(); // get the id of the target and add the moved element to the target's dom var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } function dragover_handler(ev) { console.log("dragover: dropeffect = " + ev.datatransfer.dropeffect + " ; effectallowed = " + ev.datatransfer.effectallowed); ev.preventdefault(); // set the dropeffect to move ev.datatransfer.dropeffect = "move" } </script> <body> <h1>examples <code>datatransfer</code>.{<code>dropeffect</code>, <code>effectallowed</code>} properties</h1> <d...
DataTransfer.getData() - Web APIs
owdropevent) { allowdropevent.target.style.color = 'blue'; allowdropevent.preventdefault(); } function drag(dragevent) { dragevent.datatransfer.setdata("text", dragevent.target.id); dragevent.target.style.color = 'green'; } function drop(dropevent) { dropevent.preventdefault(); var data = dropevent.datatransfer.getdata("text"); dropevent.target.appendchild(document.ge
telementbyid(data)); document.ge
telementbyid("drag").style.color = 'black'; } result specifications specification status comment html living standardthe definition of 'getdata()' in that specification.
DataTransfer.items - Web APIs
will // know which element to add to its tree ev.datatransfer.setdata("text/plain", ev.target.id); ev.datatransfer.effectallowed = "move"; } function drop_handler(ev) { console.log("drop: target.id = " + ev.target.id); ev.preventdefault(); // get the id of the target and add the moved element to the target's dom var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); // print each format type if (ev.datatransfer.types != null) { for (var i=0; i < ev.datatransfer.types.length; i++) { console.log("...
DataTransfer.setData() - Web APIs
use the event target's id for the data ev.datatransfer.setdata("text/plain", ev.target.id); } function dragover_handler(ev) { console.log("dragover"); ev.preventdefault(); } function drop_handler(ev) { console.log("drop"); ev.preventdefault(); // get the data, which is the id of the drop target var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); // clear the drag data cache (for all formats/types) ev.datatransfer.cleardata(); } </script> <body> <h1>examples of <code>datatransfer</code>: <code>setdata()</code>, <code>getdata()</code>, <code>cleardata()</code></h1> <div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> select this element, drag it to the drop zone and then release the sel...
DataTransfer.setDragImage() - Web APIs
var img = new image(); img.src = 'example.gif'; ev.datatransfer.setdragimage(img, 10, 10); } function dragover_handler(ev) { console.log("dragover"); ev.preventdefault(); } function drop_handler(ev) { console.log("drop"); ev.preventdefault(); // get the data, which is the id of the drop target var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); } </script> <body> <h1>example of <code>datatransfer.setdragimage()</code></h1> <div> <p id="source" ondragstart="dragstart_handler(event);" draggable="true"> select this element, drag it to the drop zone and then release the selection to move the element.</p> </div> <div id="target" ondrop="drop_handler(event);" ondragover="dragover_handler(event);">drop zone</div> </...
DataTransfer.types - Web APIs
will // know which element to add to its tree ev.datatransfer.setdata("text/plain", ev.target.id); ev.datatransfer.effectallowed = "move"; } function drop_handler(ev) { console.log("drop: target.id = " + ev.target.id); ev.preventdefault(); // get the id of the target and add the moved element to the target's dom var data = ev.datatransfer.getdata("text"); ev.target.appendchild(document.ge
telementbyid(data)); // print each format type if (ev.datatransfer.types != null) { for (var i=0; i < ev.datatransfer.types.length; i++) { console.log("...
DataTransferItem.getAsFile() - Web APIs
function drop_handler(ev) { console.log("drop"); ev.preventdefault(); var data = event.datatransfer.items; for (var i = 0; i < data.length; i += 1) { if ((data[i].kind == 'string') && (data[i].type.match('^text/plain'))) { // this item is the target node data[i].getasstring(function (s){ ev.target.appendchild(document.ge
telementbyid(s)); }); } else if ((data[i].kind == 'string') && (data[i].type.match('^text/html'))) { // drag data item is html console.log("...
DataTransferItem.getAsString() - Web APIs
function drop_handler(ev) { console.log("drop"); ev.preventdefault(); var data = ev.datatransfer.items; for (var i = 0; i < data.length; i += 1) { if ((data[i].kind == 'string') && (data[i].type.match('^text/plain'))) { // this item is the target node data[i].getasstring(function (s){ ev.target.appendchild(document.ge
telementbyid(s)); }); } else if ((data[i].kind == 'string') && (data[i].type.match('^text/html'))) { // drag data item is html console.log("...
Document.adoptNode() - Web APIs
example const iframe = document.queryselector('iframe'); const iframeimages = iframe.contentdocument.queryselectorall('img'); const newparent = document.ge
telementbyid('images'); iframeimages.foreach(function(imgel) { newparent.appendchild(document.adoptnode(imgel)); }); notes before they can be inserted into the current document, nodes from external documents should either be: cloned using document.importnode(); or adopted using document.adoptnode().
Document.anchors - Web APIs
example if (document.anchors.length >= 5) { dump("found too many anchors"); } the following is an example that auto populates a table of contents with every anchor on the page: <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>test</title> <script> function init() { var toc = document.ge
telementbyid("toc"); var i, li, newanchor; for (i = 0; i < document.anchors.length; i++) { li = document.createelement("li"); newanchor = document.createelement('a'); newanchor.href = "#" + document.anchors[i].name; newanchor.innerhtml = document.anchors[i].text; li.appendchild(newanchor); toc.appendchild(li); } } </script> </head> <body onload="init()"> <h1>title</h1> ...
Document.caretRangeFromPoint() - Web APIs
point) { range = document.caretrangefrompoint(e.clientx, e.clienty); textnode = range.startcontainer; offset = range.startoffset; } // only split text_nodes if (textnode && textnode.nodetype == 3) { let replacement = textnode.splittext(offset); let br = document.createelement('br'); textnode.parentnode.insertbefore(br, replacement); } } let paragraphs = document.ge
telementsbytagname("p"); for (let i = 0; i < paragraphs.length; i++) { paragraphs[i].addeventlistener('click', insertbreakatpoint, false); } result ...
Document.cookie - Web APIs
the reason for the syntax of the document.cookie accessor property is due to the client-server nature of cookies, which differs from other client-client storage methods (like, for instance, localstorage): the server
tells the client to store a cookie http/1.0 200 ok content-type: text/html set-cookie: cookie_name1=cookie_value1 set-cookie: cookie_name2=cookie_value2; expires=sun, 16 jul 3567 06:23:41 gmt [content of the page here] the client sends back to the server its cookies previously stored get /sample_page.html http/1.1 host: www.example.org cookie: cookie_name1=cookie_value1; cookie_name2=cookie_value...
Document.createAttribute() - Web APIs
example var node = document.ge
telementbyid("div1"); var a = document.createattribute("my_attrib"); a.value = "newval"; node.setattributenode(a); console.log(node.getattribute("my_attrib")); // "newval" specifications specification status comment domthe definition of 'document.createattribute()' in that specification.
Document.createCDATASection() - Web APIs
example var docu = new domparser().parsefromstring('<xml></xml>', 'application/xml') var cdata = docu.createcdatasection('some <cdata> data & then some'); docu.ge
telementsbytagname('xml')[0].appendchild(cdata); alert(new xmlserializer().serializetostring(docu)); // displays: <xml><![cdata[some <cdata> data & then some]]></xml> notes this will only work with xml, not html documents (as html documents do not support cdata sections); attempting it on an html document will throw not_supported_err.
Document.createComment() - Web APIs
example var docu = new domparser().parsefromstring('<xml></xml>', 'application/xml'); var comment = docu.createcomment('this is a not-so-secret comment in your document'); docu.ge
telementsbytagname('xml')[0].appendchild(comment); alert(new xmlserializer().serializetostring(docu)); // displays: <xml><!--this is a not-so-secret comment in your document--></xml> specifications specification status comment domthe definition of 'document.createcomment' in that specification.
Document.createDocumentFragment() - Web APIs
html <ul id="ul"> </ul> javascript var element = document.ge
telementbyid('ul'); // assuming ul exists var fragment = document.createdocumentfragment(); var browsers = ['firefox', 'chrome', 'opera', 'safari', 'internet explorer']; browsers.foreach(function(browser) { var li = document.createelement('li'); li.textcontent = browser; fragment.appendchild(li); }); element.appendchild(fragment); result specifications specification ...
Document.createElementNS() - Web APIs
m two different namespaces within a single document: <?xml version="1.0"?> <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" title="||working with elements||" onload="init()"> <script type="application/javascript"><![cdata[ let container; let newdiv; let txtnode; function init(){ container = document.ge
telementbyid("containerbox"); newdiv = document.createelementns("http://www.w3.org/1999/xhtml", "div"); txtnode = document.createtextnode("this is text that was constructed dynamically with createelementns and createtextnode then inserted into the document using appendchild."); newdiv.appendchild(txtnode); container.appendchild(newdiv); } ]]></script> <vbox id="containerbox" flex="1">...
Document.createTextNode() - Web APIs
example <!doctype html> <html lang="en"> <head> <title>createtextnode example</title> <script> function addtextnode(text) { var newtext = document.createtextnode(text), p1 = document.ge
telementbyid("p1"); p1.appendchild(newtext); } </script> </head> <body> <button onclick="addtextnode('yes!
Document.createTouch() - Web APIs
var target = document.ge
telementbyid("target"); var touch1 = document.createtouch(window, target, 1, 15, 20, 35, 40); var touch2 = document.createtouch(window, target, 2, 25, 30, 45, 50); specifications specification status comment touch eventsthe definition of 'document.createtouch()' in that specification.
Document.createTouchList() - Web APIs
var target = document.ge
telementbyid("target"); // create some touch points var touch1 = document.createtouch(window, target, 1, 15, 20, 35, 40); var touch2 = document.createtouch(window, target, 2, 25, 30, 45, 50); // create an empty touchlist objects var list0 = document.createtouchlist(); // create a touchlist with only one touch object var list1 = document.createtouchlist(touch1); // create a list with two touch obj...
Document.currentScript - Web APIs
syntax var curscrip
telement = document.currentscript; example this example checks to see if the script is being executed asynchronously: if (document.currentscript.async) { console.log("executing asynchronously"); } else { console.log("executing synchronously"); } view live examples specifications specification status comment html living standardthe definition of 'document.current...
Document.documentURI - Web APIs
syntax const uri = document.documenturi example javascript document.ge
telementbyid("url").textcontent = document.documenturi; html <p id="urltext"> url:<br/> <span id="url">url goes here</span> </p> result specifications specification status comment domthe definition of 'documenturi' in that specification.
Document.exitFullscreen() - Web APIs
document.onclick = function (event) { if (document.fullscreenelement) { document.exitfullscreen() .then(() => console.log("document exited form full screen mode")) .catch((err) => console.error(err)) } else { document.documen
telement.requestfullscreen(); } } note: for a more complete example, see the example in element.requestfullscreen().
Element: keyup event - Web APIs
<input placeholder="click here, then press and release a key." size="40"> <p id="log"></p> const input = document.queryselector('input'); const log = document.ge
telementbyid('log'); input.addeventlistener('keyup', logkey); function logkey(e) { log.textcontent += ` ${e.code}`; } onkeyup equivalent input.onkeyup = logkey; specifications specification status ui events working draft ...
Element.localName - Web APIs
example (must be served with xml content type, such as text/xml or application/xhtml+xml.) <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg"> <head> <script type="application/javascript"><![cdata[ function test() { var text = document.ge
telementbyid('text'); var circle = document.ge
telementbyid('circle'); text.value = "<svg:circle> has:\n" + "localname = '" + circle.localname + "'\n" + "namespaceuri = '" + circle.namespaceuri + "'"; } ]]></script> </head> <body onload="test()"> <svg:svg version="1.1" width="100px" height="100px" viewbox="0 0 100 100"> <svg:circle cx="50" c...
Element.matches() - Web APIs
example <ul id="birds"> <li>orange-winged parrot</li> <li class="endangered">philippine eagle</li> <li>great white pelican</li> </ul> <script type="text/javascript"> var birds = document.ge
telementsbytagname('li'); for (var i = 0; i < birds.length; i++) { if (birds[i].matches('.endangered')) { console.log('the ' + birds[i].textcontent + ' is endangered!'); } } </script> this will log "the philippine eagle is endangered!" to the console, since the element has indeed a class attribute with value endangered.
Element: mousedown event - Web APIs
html <h1>drawing with mouse events</h1> <canvas id="mypics" width="560" height="360"></canvas> css canvas { border: 1px solid black; width: 560px; height: 360px; } javascript // when true, moving the mouse draws on the canvas let isdrawing = false; let x = 0; let y = 0; const mypics = document.ge
telementbyid('mypics'); const context = mypics.getcontext('2d'); // event.offsetx, event.offsety gives the (x,y) offset from the edge of the canvas.
Element: mouseenter event - Web APIs
#mousetarget { box-sizing: border-box; width:15rem; border:1px solid #333; } javascript var entereventcount = 0; var leaveeventcount = 0; const mousetarget = document.ge
telementbyid('mousetarget'); const unorderedlist = document.ge
telementbyid('unorderedlist'); mousetarget.addeventlistener('mouseenter', e => { mousetarget.style.border = '5px dotted orange'; entereventcount++; addlistitem('this is mouseenter event ' + entereventcount + '.'); }); mousetarget.addeventlistener('mouseleave', e => { mousetarget.style.border = '1px solid #333'; leaveeventcount+...
Element: mouseleave event - Web APIs
#mousetarget { box-sizing: border-box; width:15rem; border:1px solid #333; } javascript var entereventcount = 0; var leaveeventcount = 0; const mousetarget = document.ge
telementbyid('mousetarget'); const unorderedlist = document.ge
telementbyid('unorderedlist'); mousetarget.addeventlistener('mouseenter', e => { mousetarget.style.border = '5px dotted orange'; entereventcount++; addlistitem('this is mouseenter event ' + entereventcount + '.'); }); mousetarget.addeventlistener('mouseleave', e => { mousetarget.style.border = '1px solid #333'; leaveeventcount+...
Element: mousemove event - Web APIs
html <h1>drawing with mouse events</h1> <canvas id="mypics" width="560" height="360"></canvas> css canvas { border: 1px solid black; width: 560px; height: 360px; } javascript // when true, moving the mouse draws on the canvas let isdrawing = false; let x = 0; let y = 0; const mypics = document.ge
telementbyid('mypics'); const context = mypics.getcontext('2d'); // event.offsetx, event.offsety gives the (x,y) offset from the edge of the canvas.
Element: mouseout event - Web APIs
html <ul id="test"> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> javascript let test = document.ge
telementbyid("test"); // briefly make the list purple when the mouse moves off the // <ul> element test.addeventlistener("mouseleave", function( event ) { // highlight the mouseleave target event.target.style.color = "purple"; // reset the color after a short delay settimeout(function() { event.target.style.color = ""; }, 1000); }, false); // briefly make an <li> orange when the mous...
Element: mouseover event - Web APIs
html <ul id="test"> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> javascript let test = document.ge
telementbyid("test"); // this handler will be executed only once when the cursor // moves over the unordered list test.addeventlistener("mouseenter", function( event ) { // highlight the mouseenter target event.target.style.color = "purple"; // reset the color after a short delay settimeout(function() { event.target.style.color = ""; }, 500); }, false); // this handler will be execut...
Element: mouseup event - Web APIs
html <h1>drawing with mouse events</h1> <canvas id="mypics" width="560" height="360"></canvas> css canvas { border: 1px solid black; width: 560px; height: 360px; } javascript // when true, moving the mouse draws on the canvas let isdrawing = false; let x = 0; let y = 0; const mypics = document.ge
telementbyid('mypics'); const context = mypics.getcontext('2d'); // event.offsetx, event.offsety gives the (x,y) offset from the edge of the canvas.
Element.name - Web APIs
name can be used in the document.ge
telementsbyname() method, a form and with the form elements collection.
Element: overflow event - Web APIs
s <div id="wrapper"> <div id="child"></div> </div> <br/> <label><input type="checkbox" id="toggle" checked/> overflow</label> <style> #wrapper { width: 20px; height: 20px; background: #000; padding: 5px; overflow: hidden; } #child { width: 40px; height: 40px; border: 2px solid grey; background: #ccc; } </style> <script> var wrapper = document.ge
telementbyid("wrapper"), child = document.ge
telementbyid("child"), toggle = document.ge
telementbyid("toggle"); wrapper.addeventlistener("overflow", function( event ) { console.log( event ); }, false); wrapper.addeventlistener("underflow", function( event ) { console.log( event ); }, false); toggle.addeventlistener("change", function( event ) { if ( event.tar...
Element.querySelector() - Web APIs
html <div> <h5>original content</h5> <p> inside paragraph <span>inside span</span> inside paragraph </p> </div> <div> <h5>output</h5> <div id="output"></div> </div> javascript var baseelement = document.queryselector("p"); document.ge
telementbyid("output").innerhtml = (baseelement.queryselector("div span").innerhtml); result the result looks like this: notice how the "div span" selector still successfully matches the <span> element, even though the baseelement's child nodes do not include the div element (it is still part of the specified selector).
Element.removeAttribute() - Web APIs
aware methods for dealing with attr nodes directly (seldom used) setattribute (dom 1) setattributens setattributenode setattributenodens getattribute (dom 1) getattributens getattributenode getattributenodens hasattribute (dom 2) hasattributens - - removeattribute (dom 1) removeattributens removeattributenode - example // given: <div id="div1" align="left" width="200px"> document.ge
telementbyid("div1").removeattribute("align"); // now: <div id="div1" width="200px"> specifications specification status comment domthe definition of 'element" removeattribute' in that specification.
Element.removeAttributeNS() - Web APIs
example // given: // <div id="div1" xmlns:special="http://www.mozilla.org/ns/specialspace" // special:specialalign="utterleft" width="200px" /> d = document.ge
telementbyid("div1"); d.removeattributens("http://www.mozilla.org/ns/specialspace", "specialalign"); // now: <div id="div1" width="200px" /> notes dom methods dealing with element's attributes: not namespace-aware, most commonly used methods namespace-aware variants (dom level 2) dom level 1 methods for dealing with attr nodes directly (seldom used) dom level 2 namespace-aware methods for deali...
Element.removeAttributeNode() - Web APIs
example // given: <div id="top" align="center" /> var d = document.ge
telementbyid("top"); var d_align = d.getattributenode("align"); d.removeattributenode(d_align); // align is now removed: <div id="top" /> notes if the removed attribute has a default value, it is immedia
tely replaced.
Element.scrollIntoView() - Web APIs
example var element = document.ge
telementbyid("box"); element.scrollintoview(); element.scrollintoview(false); element.scrollintoview({block: "end"}); element.scrollintoview({behavior: "smooth", block: "end", inline: "nearest"}); notes the element may not be scrolled comple
tely to the top or bottom depending on the layout of other elements.
Element.scrollIntoViewIfNeeded() - Web APIs
example var element = document.ge
telementbyid("my-el"); element.scrollintoviewifneeded(); element.scrollintoviewifneeded(true); // centers the element in the visible area specifications not part of any specification.
Element.scrollLeft - Web APIs
example html <div id="container"> <div id="content">click the button to slide right!</div> </div> <button id="slide" type="button">slide right</button> css #container { width: 100px; height: 100px; border: 1px solid #ccc; overflow-x: scroll; } #content { width: 250px; background-color: #ccc; } javascript const button = document.ge
telementbyid('slide'); button.onclick = function () { document.ge
telementbyid('container').scrollleft += 20; }; result specifications specification status comment css object model (cssom) view modulethe definition of 'scrollleft' in that specification.
Element.scrollTop - Web APIs
var in
telemscrolltop = someelement.scrolltop; after running this code, in
telemscrolltop is an integer corresponding to the number of pixels that the element's content has been scrolled upwards.
Element.scrollWidth - Web APIs
margin-bottom: 2em; } </style> </head> <body> <div id="adiv"> foobar-foobar-foobar-foobar </div> <button id="abutton"> check for overflow </button> <div id="anotherdiv"> foobar-foobar-foobar-foobar </div> <button id="anotherbutton"> check for overflow </button> </body> <script> var buttonone = document.ge
telementbyid('abutton'), buttontwo = document.ge
telementbyid('anotherbutton'), divone = document.ge
telementbyid('adiv'), divtwo = document.ge
telementbyid('anotherdiv'); //check to determine if an overflow is happening function isoverflowing(element) { return (element.scrollwidth > element.offsetwidth); } function alertoverflow(element) { if (isoverflowing...
Element: select event - Web APIs
examples selection logger <input value="try selecting some text in this element."> <p id="log"></p> function logselection(event) { const log = document.ge
telementbyid('log'); const selection = event.target.value.substring(event.target.selectionstart, event.target.selectionend); log.textcontent = `you selected: ${selection}`; } const input = document.queryselector('input'); input.addeventlistener('select', logselection); onselect equivalent you can also set up the event handler using the onselect property: input.onselect = logselection; spec...
Element.setAttributeNS() - Web APIs
example let d = document.ge
telementbyid('d1'); d.setattributens('http://www.mozilla.org/ns/specialspace', 'spec:align', 'center'); notes dom methods dealing with element's attributes: not namespace-aware, most commonly used methods namespace-aware variants (dom level 2) dom level 1 methods for dealing with attr nodes directly (seldom used) dom level 2 namespace-aware methods for dealing with attr nodes directly (seldom u...
Element.setAttributeNode() - Web APIs
html <div id="one" align="left">one</div> <div id="two">two</div> javascript let d1 = document.ge
telementbyid('one'); let d2 = document.ge
telementbyid('two'); let a = d1.getattributenode('align'); d2.setattributenode(a.clonenode(true)); // returns: 'left' alert(d2.attributes[1].value); notes if the attribute named already exists on the element, that attribute is replaced with the new one and the replaced one is returned.
Element.setAttributeNodeNS() - Web APIs
example // <div id="one" xmlns:myns="http://www.mozilla.org/ns/specialspace" // myns:special-align="utterleft">one</div> // <div id="two">two</div> var myns = "http://www.mozilla.org/ns/specialspace"; var d1 = document.ge
telementbyid("one"); var d2 = document.ge
telementbyid("two"); var a = d1.getattributenodens(myns, "special-align"); d2.setattributenodens(a.clonenode(true)); alert(d2.attributes[1].value) // returns: `utterleft' notes if the specified attribute already exists on the element, then that attribute is replaced with the new one and the replaced one is returned.
Element: show event - Web APIs
bubbles no cancelable no interface event event handler property onshow examples <div contextmenu="test"></div> <menu type="context" id="test"> <menuitem label="alert" onclick="alert('the alert label has been clicked')" /> </menu> <script> document.ge
telementbyid("test").addeventlistener("show", function(e){ alert("the context menu will be displayed"); }, false); </script> specifications specification status html5the definition of 'show event' in that specification.
Element.tagName - Web APIs
example html <span id="born">when i was born...</span> javascript var span = document.ge
telementbyid("born"); console.log(span.tagname); in xhtml (or any other xml format), the original case will be maintained, so "span" would be output in case the original tag name was created lowercase.
Element: underflow event - Web APIs
s <div id="wrapper"> <div id="child"></div> </div> <br/> <label><input type="checkbox" id="toggle" checked/> overflow</label> <style> #wrapper { width: 20px; height: 20px; background: #000; padding: 5px; overflow: hidden; } #child { width: 40px; height: 40px; border: 2px solid grey; background: #ccc; } </style> <script> var wrapper = document.ge
telementbyid("wrapper"), child = document.ge
telementbyid("child"), toggle = document.ge
telementbyid("toggle"); wrapper.addeventlistener("overflow", function( event ) { console.log( event ); }, false); wrapper.addeventlistener("underflow", function( event ) { console.log( event ); }, false); toggle.addeventlistener("change", function( event ) { if ( event.tar...
Event.currentTarget - Web APIs
function hide(e){ e.currenttarget.style.visibility = 'hidden'; console.log(e.currenttarget); // when this function is used as an event handler: this === e.currenttarget } var ps = document.ge
telementsbytagname('p'); for(var i = 0; i < ps.length; i++){ // console: print the clicked <p> element ps[i].addeventlistener('click', hide, false); } // console: print <body> document.body.addeventlistener('click', hide, false); // click around and make paragraphs disappear note: the value of event.currenttarget is only available while the event is being handled.
Event.defaultPrevented - Web APIs
html <p><a id="link1" href="#link1">visit link 1</a></p> <p><a id="link2" href="#link2">try to visit link 2</a> (you can't)</p> <p id="log"></p> javascript function stoplink(event) { event.preventdefault(); } function logclick(event) { const log = document.ge
telementbyid('log'); if (event.target.tagname === 'a') { if (event.defaultprevented) { log.innertext = 'sorry, but you cannot visit this link!\n' + log.innertext; } else { log.innertext = 'visiting link...\n' + log.innertext; } } } const a = document.ge
telementbyid('link2'); a.addeventlistener('click', stoplink); document.addeventlistener('click', logclick); result ...
Event.eventPhase - Web APIs
<div id="d4">d4</div> </div> </div> </div> <div id="divinfo"></div> css div { margin: 20px; padding: 4px; border: thin black solid; } #divinfo { margin: 18px; padding: 8px; background-color:white; font-size:80%; } javascript let clear = false, divinfo = null, divs = null, usecapture = false; window.onload = function () { divinfo = document.ge
telementbyid('divinfo') divs = document.ge
telementsbytagname('div') chcapture = document.ge
telementbyid('chcapture') chcapture.onclick = function () { removelisteners() addlisteners() } clear() addlisteners() } function removelisteners() { for (let i = 0; i < divs.length; i++) { let d = divs[i] if (d.id != "divinfo") { d.removeeventlistener("click", ondivclick, tr...
Event.msConvertURL() - Web APIs
example var bloblist = []; document.ge
telementbyid("pastezone").addeventlistener('paste', handlepaste, false); function handlepaste(evt) { var filelist = window.clipboarddata.files; // note that window.datatransfer.files is not applicable.
Event.timeStamp - Web APIs
</p> <p>timestamp: <span id="time">-</span></p> javascript function gettime(event) { var time = document.ge
telementbyid("time"); time.firstchild.nodevalue = event.timestamp; } document.body.addeventlistener("keypress", gettime); result reduced time precision to offer protection against timing attacks and fingerprinting, the precision of event.timestamp might get rounded depending on browser settings.
Event.type - Web APIs
html <p>press any key or click the mouse to get the event type.</p> <p id="log"></p> javascript function geteventtype(event) { const log = document.ge
telementbyid('log'); log.innertext = event.type + '\n' + log.innertext; } // keyboard events document.addeventlistener('keydown', geteventtype, false); // first document.addeventlistener('keypress', geteventtype, false); // second document.addeventlistener('keyup', geteventtype, false); // third // mouse events document.addeventlistener('mousedown', geteventtype, false); // first document.add...
EventListener - Web APIs
example html <button id="btn">click here!</button> javascript const buttonelement = document.ge
telementbyid('btn'); // add a handler for the 'click' event by providing a callback function.
File.getAsBinary() - Web APIs
example // fileinput is an htmlinpu
telement: <input type="file" id="myfileinput" multiple> var fileinput = document.ge
telementbyid("myfileinput"); // files is a filelist object (similar to nodelist) var files = fileinput.files; // object for allowed media types var accept = { binary : ["image/png", "image/jpeg"], text : ["text/plain", "text/css", "application/xml", "text/html"] }; var file; for (var i = 0; i < files.length; ...
File.getAsDataURL() - Web APIs
syntax var url = instanceoffile.getasdataurl(); returns a string representing a data: url example // fileinput is a htmlinpu
telement: <input type="file" id="myfileinput" multiple> var fileinput = document.ge
telementbyid("myfileinput"); // files is a filelist object (similar to nodelist) var files = fileinput.files; // array with acceptable file types var accept = ["image/png"]; // img is a htmlimgelement: <img id="myimg"> var img = document.ge
telementbyid("myimg"); // if we accept the first selected file type if (accept.indexof(files[0].mediatype) > -1) { // display the image //...
File.getAsText() - Web APIs
example // fileinput is a htmlinpu
telement: <input type="file" id="myfileinput" multiple> var fileinput = document.ge
telementbyid("myfileinput"); // files is a filelist object (similar to nodelist) var files = fileinput.files; // object for allowed media types var accept = { binary : ["image/png", "image/jpeg"], text : ["text/plain", "text/css", "application/xml", "text/html"] }; var file; for (var i = 0; i < files.length; ...
File.lastModifiedDate - Web APIs
example // fileinput is a htmlinpu
telement: <input type="file" multiple id="myfileinput"> var fileinput = document.ge
telementbyid("myfileinput"); // files is a filelist object (simliar to nodelist) var files = fileinput.files; for (var i = 0; i < files.length; i++) { alert(files[i].name + " has a last modified date of " + files[i].lastmodifieddate); } reduced time precision to offer protection against timing attacks and fingerprinting, the precision of somefile.lastmodifieddate.gettime() mi...
File.webkitRelativePath - Web APIs
html content <input type="file" id="filepicker" name="filelist" webkitdirectory multiple /> <ul id="listing"></ul> javascript content document.ge
telementbyid("filepicker").addeventlistener("change", function(event) { let output = document.ge
telementbyid("listing"); let files = event.target.files; for (let i=0; i<files.length; i++) { let item = document.createelement("li"); item.innerhtml = files[i].webkitrelativepath; output.appendchild(item); }; }, false); result specifications specification status c...
FileSystem - Web APIs
it's not available for use in file or folder picker panels (such as when you use an <input> element with the htmlinpu
telement.webkitdirectory attribute.firefox full support 50ie no support noopera full support 15prefixed full support 15prefixed prefixed implemented with the vendor prefix: webkitsafari full support ...
FileSystemDirectoryReader.readEntries() - Web APIs
let dropzone = document.ge
telementbyid("dropzone"); let listing = document.ge
telementbyid("listing"); function scanfiles(item, container) { let elem = document.createelement("li"); elem.innerhtml = item.name; container.appendchild(elem); if (item.isdirectory) { let directoryreader = item.createreader(); let directorycontainer = document.createelement("ul"); container.appendchild(directorycontainer); d...
HTMLButtonElement.labels - Web APIs
example html <label id="label1" for="test">label 1</label> <button id="test">button</button> <label id="label2" for="test">label 2</label> javascript window.addeventlistener("domcontentloaded", function() { const button = document.ge
telementbyid("test"); for(var i = 0; i < button.labels.length; i++) { console.log(button.labels[i].textcontent); // "label 1" and "label 2" } }); specifications specification status comment html living standardthe definition of 'labels' in that specification.
HTMLCanvasElement.getContext() - Web APIs
examples given this <canvas> element: <canvas id="canvas" width="300" height="300"></canvas> you can get a 2d context of the canvas with the following code: var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); console.log(ctx); // canvasrenderingcontext2d { ...
HTMLCanvasElement.height - Web APIs
syntax var pxl = canvas.height; canvas.height = pxl; examples given this <canvas> element: <canvas id="canvas" width="300" height="300"></canvas> you can get the height of the canvas with the following code: var canvas = document.ge
telementbyid('canvas'); console.log(canvas.height); // 300 specifications specification status comment html living standardthe definition of 'htmlcanvaselement.height' in that specification.
HTMLCanvasElement.mozFetchAsStream() - Web APIs
also uses netutil.jsm var canvas = document.ge
telementbyid('canvas'); var d = canvas.width; ctx = canvas.getcontext('2d'); ctx.beginpath(); ctx.moveto(d / 2, 0); ctx.lineto(d, d); ctx.lineto(0, d); ctx.closepath(); ctx.fillstyle = 'yellow'; ctx.fill(); var netutilcallback = function() { return function(result) { if (!components.issuccesscode(result)) { alert('failed to create icon'); } else { alert('succes...
HTMLCanvasElement.mozGetAsFile() - Web APIs
function draw() { var canvas = document.ge
telementbyid('canvas'); var ctx = canvas.getcontext('2d'); ctx.fillstyle = 'rgb(200, 0, 0)'; ctx.fillrect(10, 10, 55, 50); ctx.fillstyle = 'rgba(0, 0, 200, 0.5)'; ctx.fillrect(30, 30, 55, 50); var link = document.ge
telementbyid('link'); link.addeventlistener('click', copy); } function copy() { var canvas = document.ge
telementbyid('canvas'); var f = canvas.mozgetasfile('test.png'...
HTMLCanvasElement.mozOpaque - Web APIs
var canvas = document.ge
telementbyid('canvas'); console.log(canvas.mozopaque); // true // deactivate it canvas.mozopaque = false; specifications not part of any standard.
HTMLCanvasElement: webglcontextcreationerror event - Web APIs
bubbles yes cancelable yes interface webglcontextevent event handler property none example var canvas = document.ge
telementbyid('canvas'); canvas.addeventlistener('webglcontextcreationerror', function(e) { console.log(e.statusmessage || 'unknown error'); }, false); var gl = canvas.getcontext('webgl'); // logs statusmessage or "unknown error" if unable to create webgl context specifications specification status comment webgl 1.0the definition of 'webglcontextcreationerror' in that sp...
HTMLCanvasElement: webglcontextlost event - Web APIs
bubbles yes cancelable yes interface webglcontextevent event handler property none example with the help of the webgl_lose_context extension, you can simulate the webglcontextlost event: const canvas = document.ge
telementbyid('canvas'); const gl = canvas.getcontext('webgl'); canvas.addeventlistener('webglcontextlost', (event) => { console.log(event); }); gl.getextension('webgl_lose_context').losecontext(); // "webglcontextlost" event is logged.
HTMLCanvasElement: webglcontextrestored event - Web APIs
bubbles yes cancelable yes interface webglcontextevent event handler property none example with the help of the webgl_lose_context extension, you can simulate the webglcontextrestored event: var canvas = document.ge
telementbyid('canvas'); var gl = canvas.getcontext('webgl'); canvas.addeventlistener('webglcontextrestored', function(e) { console.log(e); }, false); gl.getextension('webgl_lose_context').restorecontext(); // "webglcontextrestored" event is logged.
HTMLCanvasElement.width - Web APIs
syntax var pxl = canvas.width; canvas.width = pxl; examples given this <canvas> element: <canvas id="canvas" width="300" height="300"></canvas> you can get the width of the canvas with the following code: var canvas = document.ge
telementbyid('canvas'); console.log(canvas.width); // 300 specifications specification status comment html living standardthe definition of 'htmlcanvaselement.width' in that specification.
HTMLDialogElement.close() - Web APIs
tion>red panda</option> <option>spider monkey</option> </select></p> </section> <menu> <button id="cancel" type="reset">cancel</button> <button type="submit">confirm</button> </menu> </form> </dialog> <menu> <button id="updatedetails">update details</button> </menu> <script> (function() { var updatebutton = document.ge
telementbyid('updatedetails'); var cancelbutton = document.ge
telementbyid('cancel'); var dialog = document.ge
telementbyid('favdialog'); dialog.returnvalue = 'favanimal'; function opencheck(dialog) { if(dialog.open) { console.log('dialog open'); } else { console.log('dialog closed'); } } // update button opens a modal di...
HTMLDialogElement.open - Web APIs
tion>red panda</option> <option>spider monkey</option> </select></p> </section> <menu> <button id="cancel" type="reset">cancel</button> <button type="submit">confirm</button> </menu> </form> </dialog> <menu> <button id="updatedetails">update details</button> </menu> <script> (function() { var updatebutton = document.ge
telementbyid('updatedetails'); var cancelbutton = document.ge
telementbyid('cancel'); var dialog = document.ge
telementbyid('favdialog'); dialog.returnvalue = 'favanimal'; function opencheck(dialog) { if(dialog.open) { console.log('dialog open'); } else { console.log('dialog closed'); } } // update button opens a modal di...
HTMLDialogElement.returnValue - Web APIs
ption>brine shrimp</option> <option>red panda</option> <option>spider monkey</option> </select> </label></p> <menu> <button>cancel</button> <button>confirm</button> </menu> </form> </dialog> <menu> <button id="updatedetails">update details</button> </menu> <script> (function() { var updatebutton = document.ge
telementbyid('updatedetails'); var dialog = document.ge
telementbyid('favdialog'); dialog.returnvalue = 'favanimal'; function opencheck(dialog) { if (dialog.open) { console.log('dialog open'); } else { console.log('dialog closed'); } } function handleuserinput(returnvalue) { if (returnvalue === 'cancel' || returnvalue ...
HTMLDialogElement.show() - Web APIs
tion>red panda</option> <option>spider monkey</option> </select></p> </section> <menu> <button id="cancel" type="reset">cancel</button> <button type="submit">confirm</button> </menu> </form> </dialog> <menu> <button id="updatedetails">update details</button> </menu> <script> (function() { var updatebutton = document.ge
telementbyid('updatedetails'); var cancelbutton = document.ge
telementbyid('cancel'); var dialog = document.ge
telementbyid('favdialog'); dialog.returnvalue = 'favanimal'; function opencheck(dialog) { if(dialog.open) { console.log('dialog open'); } else { console.log('dialog closed'); } } // update button opens a modal di...
HTMLDialogElement.showModal() - Web APIs
tion>red panda</option> <option>spider monkey</option> </select></p> </section> <menu> <button id="cancel" type="reset">cancel</button> <button type="submit">confirm</button> </menu> </form> </dialog> <menu> <button id="updatedetails">update details</button> </menu> <script> (function() { var updatebutton = document.ge
telementbyid('updatedetails'); var cancelbutton = document.ge
telementbyid('cancel'); var dialog = document.ge
telementbyid('favdialog'); dialog.returnvalue = 'favanimal'; function opencheck(dialog) { if(dialog.open) { console.log('dialog open'); } else { console.log('dialog closed'); } } // update button opens a modal di...
MouseEvent.pageX - Web APIs
javascript var box = document.queryselector(".box"); var pagex = document.ge
telementbyid("x"); var pagey = document.ge
telementbyid("y"); function updatedisplay(event) { pagex.innertext = event.pagex; pagey.innertext = event.pagey; } box.addeventlistener("mousemove", updatedisplay, false); box.addeventlistener("mouseenter", updatedisplay, false); box.addeventlistener("mouseleave", updatedisplay, false); the javascript code uses addeventlistener() to register the functi...
MouseEvent.region - Web APIs
<canvas id="canvas"></canvas> <script> var canvas = document.ge
telementbyid("canvas"); var ctx = canvas.getcontext("2d"); ctx.beginpath(); ctx.arc(70, 80, 10, 0, 2 * math.pi, false); ctx.fill(); ctx.addhitregion({id: "circle"}); canvas.addeventlistener("mousemove", function(event){ if(event.region) { console.log("hit region: " + event.region); } }); </script> ...
MouseEvent.relatedTarget - Web APIs
html <body id="body"> <div id="outer"> <div id="red"></div> <div id="blue"></div> </div> <p id="log"></p> </body> css #outer { width: 250px; height: 125px; display: flex; } #red { flex-grow: 1; background: red; } #blue { flex-grow: 1; background: blue; } #log { max-height: 120px; overflow-y: scroll; } javascript const mouseoutlog = document.ge
telementbyid('log'), red = document.ge
telementbyid('red'), blue = document.ge
telementbyid('blue'); red.addeventlistener('mouseover', overlistener); red.addeventlistener('mouseout', outlistener); blue.addeventlistener('mouseover', overlistener); blue.addeventlistener('mouseout', outlistener); function outlistener(event) { let related = event.relatedtarget ?
MouseEvent - Web APIs
html <p><label><input type="checkbox" id="checkbox"> checked</label> <p><button id="button">click me</button> javascript function simulateclick() { var evt = new mouseevent("click", { bubbles: true, cancelable: true, view: window }); var cb = document.ge
telementbyid("checkbox"); //element to click on var canceled = !cb.dispatchevent(evt); if(canceled) { // a handler called preventdefault alert("canceled"); } else { // none of the handlers called preventdefault alert("not canceled"); } } document.ge
telementbyid("button").addeventlistener('click', simulateclick); result specifications specification status co...
msPlayToSource - Web APIs
e.sourcerequest.setsource(document.ge
telementbyid("videoplayer").msplaytosource); // the media will then be streamed to the device chosen by the user in the ui.
MutationObserver.observe() - Web APIs
// identify an element to observe const elementtoobserve = document.queryselector("#targe
telementid"); // create a new instance of `mutationobserver` named `observer`, // passing it a callback function const observer = new mutationobserver(function() { console.log('callback that runs when observer is triggered'); }); // call `observe()` on that mutationobserver instance, // passing it the element to observe, and the options object observer.observe(elementtoobserve, {subtree: true, ...
MutationObserver - Web APIs
// select the node that will be observed for mutations const targetnode = document.ge
telementbyid('some-id'); // options for the observer (which mutations to observe) const config = { attributes: true, childlist: true, subtree: true }; // callback function to execute when mutations are observed const callback = function(mutationslist, observer) { // use traditional 'for loops' for ie 11 for(let mutation of mutationslist) { if (mutation.type === 'childlist') { ...
MutationObserverInit.attributeFilter - Web APIs
tation) { switch(mutation.type) { case "attributes": switch(mutation.attributename) { case "status": userstatuschanged(mutation.target.username, mutation.target.status); break; case "username": usernamechanged(mutation.oldvalue, mutation.target.username); break; } break; } }); } var userlis
telement = document.queryselector("#userlist"); var observer = new mutationobserver(callback); observer.observe(userlis
telement, { attributefilter: [ "status", "username" ], attributeoldvalue: true, subtree: true }); the callback() function—which will be passed into the observe() method when starting the observer, looks at each item in the list of mutationrecord objects.
MutationObserverInit.attributeOldValue - Web APIs
for any items representing an attribute change (which can be detected by the value of mutationrecord.type being "attributes"), a function called notifyuser() is used to
tell the user the name of the attribute that changed as well as the attribute's new value (mutation.target[mutation.attributename]) and its old value (mutation.oldvalue).
MutationObserverInit.attributes - Web APIs
for any items representing an attribute change (which can be detected by the value of mutationrecord.type being "attributes"), a function called notifyuser() is used to
tell the user the name of the attribute that changed as well as the attribute's new value (mutation.target[mutation.attributename]) and its old value (mutation.oldvalue).
NDEFReader.scan() - Web APIs
return value a promise that resolves with undefined immedia
telly after scheduling read operations for the nfc adapter.
Navigator.oscpu - Web APIs
system oscpuinfo string format os/2 os/2 warp x (either 3, 4 or 4.5) windows ce windowsce x.y1 windows 64-bit (64-bit build) windows nt x.y; win64; x64 windows 64-bit (32-bit build) windows nt x.y; wow64 windows 32-bit windows nt x.y mac os x (ppc build) powerpc mac os x version x.y mac os x (i386/x64 build) in
tel mac os x or macos version x.y linux 64-bit (32-bit build) output of uname -s plus "i686 on x86_64" linux output of uname -sm x.y refers to the version of the operating system example function osinfo() { alert(window.navigator.oscpu); } osinfo(); // alerts "windows nt 6.0" for example usage notes unless your code is privileged (chrome or at least has the u...
Navigator.productSub - Web APIs
example <script> function prodsub() { var dt = document.ge
telementbyid("d").childnodes[0]; dt.data = window.navigator.productsub; } </script> <button onclick="prodsub();">productsub</button> // returns: 20010725 notes on ie, this property returns undefined.
OrientationSensor - Web APIs
examples basic example the following example, which is loosely based on in
tel's orientation phone demo, instantiates an absoluteorientationsensor with a frequency of 60 times a second.
PannerNode.coneInnerAngle - Web APIs
effect // (otherwise the sound is located at the same position as the listener) panner.positionz.setvalueattime(1, context.currenttime); having set up the pannernode, we can now schedule some updates to its y-axis rotation: // calculate the vector for no rotation // this means the sound will play at full volume const [x1, y1, z1] = yrotationtovector(0); // schedule the no-rotation vector immedia
tely panner.orientationx.setvalueattime(x1, context.currenttime); panner.orientationy.setvalueattime(y1, context.currenttime); panner.orientationz.setvalueattime(z1, context.currenttime); // calculate the vector for -22.4 degrees // since our coneouterangle is 45, this will just about make the sound audible // if we set it to +/-22.5, the sound volume will be 0, as the threshold is exclusive const [...
PannerNode.coneOuterAngle - Web APIs
effect // (otherwise the sound is located at the same position as the listener) panner.positionz.setvalueattime(1, context.currenttime); having set up the pannernode, we can now schedule some updates to its y-axis rotation: // calculate the vector for no rotation // this means the sound will play at full volume const [x1, y1, z1] = yrotationtovector(0); // schedule the no-rotation vector immedia
tely panner.orientationx.setvalueattime(x1, context.currenttime); panner.orientationy.setvalueattime(y1, context.currenttime); panner.orientationz.setvalueattime(z1, context.currenttime); // calculate the vector for -22.4 degrees // since our coneouterangle is 45, this will just about make the sound audible // if we set it to +/-22.5, the sound volume will be 0, as the threshold is exclusive const [...
PannerNode.coneOuterGain - Web APIs
effect // (otherwise the sound is located at the same position as the listener) panner.positionz.setvalueattime(1, context.currenttime); having set up the pannernode, we can now schedule some updates to its y-axis rotation: // calculate the vector for no rotation // this means the sound will play at full volume const [x1, y1, z1] = yrotationtovector(0); // schedule the no-rotation vector immedia
tely panner.orientationx.setvalueattime(x1, context.currenttime); panner.orientationy.setvalueattime(y1, context.currenttime); panner.orientationz.setvalueattime(z1, context.currenttime); // calculate the vector for -22.4 degrees // since our coneouterangle is 45, this will just about make the sound audible // if we set it to +/-22.5, the sound volume will be 0, as the threshold is exclusive const [...
PannerNode.orientationX - Web APIs
effect // (otherwise the sound is located at the same position as the listener) panner.positionz.setvalueattime(1, context.currenttime); having set up the pannernode, we can now schedule some updates to its y-axis rotation: // calculate the vector for no rotation // this means the sound will play at full volume const [x1, y1, z1] = yrotationtovector(0); // schedule the no-rotation vector immedia
tely panner.orientationx.setvalueattime(x1, context.currenttime); panner.orientationy.setvalueattime(y1, context.currenttime); panner.orientationz.setvalueattime(z1, context.currenttime); // calculate the vector for -22.4 degrees // since our coneouterangle is 45, this will just about make the sound audible // if we set it to +/-22.5, the sound volume will be 0, as the threshold is exclusive const [...
PannerNode.orientationY - Web APIs
effect // (otherwise the sound is located at the same position as the listener) panner.positionz.setvalueattime(1, context.currenttime); having set up the pannernode, we can now schedule some updates to its y-axis rotation: // calculate the vector for no rotation // this means the sound will play at full volume const [x1, y1, z1] = yrotationtovector(0); // schedule the no-rotation vector immedia
tely panner.orientationx.setvalueattime(x1, context.currenttime); panner.orientationy.setvalueattime(y1, context.currenttime); panner.orientationz.setvalueattime(z1, context.currenttime); // calculate the vector for -22.4 degrees // since our coneouterangle is 45, this will just about make the sound audible // if we set it to +/-22.5, the sound volume will be 0, as the threshold is exclusive const [...
PannerNode.orientationZ - Web APIs
effect // (otherwise the sound is located at the same position as the listener) panner.positionz.setvalueattime(1, context.currenttime); having set up the pannernode, we can now schedule some updates to its y-axis rotation: // calculate the vector for no rotation // this means the sound will play at full volume const [x1, y1, z1] = yrotationtovector(0); // schedule the no-rotation vector immedia
tely panner.orientationx.setvalueattime(x1, context.currenttime); panner.orientationy.setvalueattime(y1, context.currenttime); panner.orientationz.setvalueattime(z1, context.currenttime); // calculate the vector for -22.4 degrees // since our coneouterangle is 45, this will just about make the sound audible // if we set it to +/-22.5, the sound volume will be 0, as the threshold is exclusive const [...
PannerNode.refDistance - Web APIs
nnernode(context); panner.refdistance = refdistance; // set the initial z position, then schedule the ramp panner.positionz.setvalueattime(0, starttime); panner.positionz.linearramptovalueattime(z_distance, starttime + note_length); osc.connect(panner) .connect(context.destination); osc.start(starttime); osc.stop(starttime + note_length); }; // this tone should decay immedia
tely and fairly quickly scheduletesttone(1, context.currenttime); // this tone should decay slower and later than the previous one scheduletesttone(4, context.currenttime + note_length); // this tone should decay only slightly, and only start decaying fairly late scheduletesttone(7, context.currenttime + note_length * 2); after running this code, the resulting waveforms should look something like th...
ParentNode.childElementCount - Web APIs
example var foo = document.ge
telementbyid('foo'); if (foo.childelementcount > 0) { // do something } polyfill for ie8 & ie9 & safari this property is comple
tely unsupported prior to ie9.
ParentNode.children - Web APIs
example const foo = document.ge
telementbyid('foo'); for (let i = 0; i < foo.children.length; i++) { console.log(foo.children[i].tagname); } polyfill // overwrites native 'children' prototype.
ParentNode.replaceChildren() - Web APIs
const noselect = document.ge
telementbyid('no'); const yesselect = document.ge
telementbyid('yes'); const nobtn = document.ge
telementbyid('to-no'); const yesbtn = document.ge
telementbyid('to-yes'); yesbtn.addeventlistener('click', () => { const selectedtransferoptions = document.queryselectorall('#no option:checked'); const existingyesoptions = document.queryselectorall('#yes option'); yesselect.replacechildren(...selected...
Path2D.addPath() - Web APIs
const canvas = document.ge
telementbyid('canvas'); const ctx = canvas.getcontext('2d'); // create first path and add a rectangle let p1 = new path2d(); p1.rect(0, 0, 100, 150); // create second path and add a rectangle let p2 = new path2d(); p2.rect(0, 0, 100, 75); // create transformation matrix that moves 200 points to the right let m = document.createelementns('http://www.w3.org/2000/svg', 'svg').createsvgmatrix(); m.a =...
PaymentAddress - Web APIs
paymentaddress.phone read only a domstring specifying the
telephone number of the recipient or contact person.
background-position-x - CSS: Cascading Style Sheets
]#where <length-percentage> = <length> | <percentage> examples basic example the following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separa
tely.
background-position-y - CSS: Cascading Style Sheets
]#where <length-percentage> = <length> | <percentage> examples basic example the following example shows a simple background image implementation, with background-position-x and background-position-y used to define the image's horizontal and vertical positions separa
tely.
background - CSS: Cascading Style Sheets
the syntax of each layer is as follows: each layer may include zero or one occurrences of any of the following values: <attachment> <bg-image> <position> <bg-size> <repeat-style> the <bg-size> value may only be included immedia
tely after <position>, separated with the '/' character, like this: "center/80%".
border-image-repeat - CSS: Cascading Style Sheets
ry out various border repetition rules on me!</div> <select id="repetition"> <option value="stretch">stretch</option> <option value="repeat">repeat</option> <option value="round">round</option> <option value="space">space</option> <option value="stretch repeat">stretch repeat</option> <option value="space round">space round</option> </select> javascript var repetition = document.ge
telementbyid("repetition"); repetition.addeventlistener("change", function (evt) { document.ge
telementbyid("bordered").style.borderimagerepeat = evt.target.value; }); results specifications specification status comment css backgrounds and borders module level 3the definition of 'border-image-repeat' in that specification.
border-image-slice - CSS: Cascading Style Sheets
>30</output> </li> </ul> css .wrapper { width: 400px; height: 300px; } div > div { width: 300px; height: 200px; border-width: 30px; border-style: solid; border-image: url(https://udn.realityripple.com/samples/56/bb98f533ef.png); border-image-slice: 30; border-image-repeat: round; } li { display: flex; place-content: center; } javascript const widthslider = document.ge
telementbyid('width'); const sliceslider = document.ge
telementbyid('slice'); const widthoutput = document.ge
telementbyid('width-output'); const sliceoutput = document.ge
telementbyid('slice-output'); const divelem = document.queryselector('div > div'); widthslider.addeventlistener('input', () => { const newvalue = widthslider.value + 'px'; divelem.style.borderwidth = newvalue; widthoutput.textc...
clip-path - CSS: Cascading Style Sheets
option> <option value="circle(100px at 110px 100px)">circle</option> <option value="url(#cross)" selected>cross</option> <option value="inset(20px round 20px)">inset</option> <option value="path('m 0 200 l 0,110 a 110,90 0,0,1 240,100 l 200 340 z')">path</option> </select> css #clipped { margin-bottom: 20px; clip-path: url(#cross); } javascript const clippathselect = document.ge
telementbyid("clippath"); clippathselect.addeventlistener("change", function (evt) { document.ge
telementbyid("clipped").style.clippath = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'clip-path' in that specification.
color-adjust - CSS: Cascading Style Sheets
for whatever reason, this is the desired appearance in any rendering environment, including on paper, so we also use color-adjust: exact to
tell the browser not to make color or style adjustments to the box when rendering it.
contain - CSS: Cascading Style Sheets
if the containing box is offscreen, the browser does not need to paint its contained elements — these must also be offscreen as they are contained comple
tely by that box.
counter-set - CSS: Cascading Style Sheets
if there isn't currently a counter of the given name on the element, the element will create a new counter of the given name with a starting value of 0 (though it may then immedia
tely set or increment that value to something different).
<custom-ident> - CSS: Cascading Style Sheets
ranch, cjk-heavenly-stem, cjk-ideographic, devanagari, ethiopic-numeric, georgian, gujarati, gurmukhi, hebrew, hiragana, hiragana-iroha, japanese-formal, japanese-informal, kannada, katakana, katakana-iroha, khmer, korean-hangul-formal, korean-hanja-formal, korean-hanja-informal, lao, lower-armenian, malayalam, mongolian, myanmar, oriya, persian, simp-chinese-formal, simp-chinese-informal, tamil,
telugu, thai, tibetan, trad-chinese-formal, trad-chinese-informal, upper-armenian, disclosure-open, and disclosure-close.
element() - CSS: Cascading Style Sheets
desktopmobilechromeedgefirefoxinternet exploreroperasafariandroid webviewchrome for androidfirefox for androidopera for androidsafari on iossamsung interne
telement() experimentalchrome no support noedge no support nofirefox full support 57prefixed full support 57prefixed prefixed implemented with the vendor prefix: -moz- no support 29 — 57prefixed...
env() - CSS: Cascading Style Sheets
to
tell the browser to use the whole available space on the screen, and so enabling us to use the env() variables, we need to add a new viewport meta value: <meta name="viewport" content="viewport-fit=cover" /> body { padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px); } in addition, unlike custo...
flex - CSS: Cascading Style Sheets
| <'flex-basis'> ] examples setting flex: auto html <div id="flex-container"> <div class="flex-item" id="flex">flex box (click to toggle raw box)</div> <div class="raw-item" id="raw">raw box</div> </div> css #flex-container { display: flex; flex-direction: row; } #flex-container > .flex-item { flex: auto; } #flex-container > .raw-item { width: 5rem; } var flex = document.ge
telementbyid("flex"); var raw = document.ge
telementbyid("raw"); flex.addeventlistener("click", function() { raw.style.display = raw.style.display == "none" ?
list-style - CSS: Cascading Style Sheets
g wcag, guideline 1.3 explanations understanding success criterion 1.3.1 | w3c understanding wcag 2.0 formal definition initial valueas each of the properties of the shorthand:list-style-type: disclist-style-position: outsidelist-style-image: noneapplies tolist itemsinheritedyescomputed valueas each of the properties of the shorthand:list-style-image: none or the image with its uri made absolu
telist-style-position: as specifiedlist-style-type: as specifiedanimation typediscrete formal syntax <'list-style-type'> | <'list-style-position'> | <'list-style-image'> examples setting list style type and position html list 1 <ul class="one"> <li>list item1</li> <li>list item2</li> <li>list item3</li> </ul> list 2 <ul class="two"> <li>list item a</li> <li>list item b</li> <li>list...
mask-clip - CSS: Cascading Style Sheets
x</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box</option> <option value="no-clip">no-clip</option> </select> javascript var clipbox = document.ge
telementbyid("clipbox"); clipbox.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.maskclip = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'mask-clip' in that specification.
mask-composite - CSS: Cascading Style Sheets
os.org/files/12676/star.svg); mask-size: 100% 100%; mask-composite: add; /* can be changed in the live sample */ } html <div id="masked"> </div> <select id="compositemode"> <option value="add">add</option> <option value="subtract">subtract</option> <option value="intersect">intersect</option> <option value="exclude">exclude</option> </select> javascript var clipbox = document.ge
telementbyid("compositemode"); clipbox.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.maskcomposite = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'mask-composite' in that specification.
mask-mode - CSS: Cascading Style Sheets
r-gradient(red, blue); mask-image: url(https://mdn.mozillademos.org/files/12668/mdn.svg); mask-mode: alpha; /* can be changed in the live sample */ } html <div id="masked"> </div> <select id="maskmode"> <option value="alpha">alpha</option> <option value="luminance">luminance</option> <option value="match-source">match-source</option> </select> javascript var maskmode = document.ge
telementbyid("maskmode"); maskmode.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.maskmode = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'mask-mode' in that specification.
mask-origin - CSS: Cascading Style Sheets
n"> <option value="content-box">content-box</option> <option value="padding-box">padding-box</option> <option value="border-box" selected>border-box</option> <option value="margin-box">margin-box</option> <option value="fill-box">fill-box</option> <option value="stroke-box">stroke-box</option> <option value="view-box">view-box</option> </select> javascript var origin = document.ge
telementbyid("origin"); origin.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.maskorigin = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'mask-origin' in that specification.
mask-position - CSS: Cascading Style Sheets
op</option> <option value="center">center</option> <option value="bottom">bottom</option> <option value="top right" selected>top right</option> <option value="center center">center center</option> <option value="bottom left">bottom left</option> <option value="10px 20px">10px 20px</option> <option value="60% 20%">60% 20%</option> </select> javascript var maskposition = document.ge
telementbyid("maskposition"); maskposition.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.maskposition = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'mask-position' in that specification.
mask-repeat - CSS: Cascading Style Sheets
10px; } html content <div id="masked"> </div> <select id="repetition"> <option value="repeat-x">repeat-x</option> <option value="repeat-y">repeat-y</option> <option value="repeat" selected>repeat</option> <option value="space">space</option> <option value="round">round</option> <option value="no-repeat">no-repeat</option> </select> javascript content var repetition = document.ge
telementbyid("repetition"); repetition.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.maskrepeat = evt.target.value; }); result multiple mask image support you can specify a different <repeat-style> for each mask image, separated by commas: .examplethree { mask-image: url('mask1.png'), url('mask2.png'); mask-repeat: repeat-x, repeat-y; } each image...
mask-size - CSS: Cascading Style Sheets
sample */ margin-bottom: 10px; } html <div id="masked"> </div> <select id="masksize"> <option value="auto">auto</option> <option value="40% 80%">40% 80%</option> <option value="50%" selected>50%</option> <option value="200px 100px">200px 100px</option> <option value="cover">cover</option> <option value="contain">contain</option> </select> javascript var masksize = document.ge
telementbyid("masksize"); masksize.addeventlistener("change", function (evt) { document.ge
telementbyid("masked").style.masksize = evt.target.value; }); result specifications specification status comment css masking module level 1the definition of 'mask-size' in that specification.
max-height - CSS: Cascading Style Sheets
if the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolu
tely positioned, the percentage value is treated as none.computed valuethe percentage as specified or the absolute length or noneanimation typea length, percentage or calc(); formal syntax auto | <length> | <percentage> | min-content | max-content | fit-content(<length-percentage>)where <length-percentage> = <length> | <percentage> examples setting max-height using percentage and keyword values ...
min-height - CSS: Cascading Style Sheets
if the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolu
tely positioned, the percentage value is treated as 0.computed valuethe percentage as specified or the absolute lengthanimation typea length, percentage or calc(); formal syntax auto | <length> | <percentage> | min-content | max-content | fit-content(<length-percentage>)where <length-percentage> = <length> | <percentage> examples setting min-height table { min-height: 75%; } form { min-height: ...
offset - CSS: Cascading Style Sheets
examples animating an element along a path html <div id="offse
telement"></div> css @keyframes move { from { offset-distance: 0%; } to { offset-distance: 100%; } } #offse
telement { width: 50px; height: 50px; background-color: blue; offset: path("m 100 100 l 300 100 l 200 300 z") auto; animation: move 3s linear infinite; } result specifications specification status comment motion path module level 1the ...