Search completed in 1.12 seconds.
Document.createElementNS() - Web APIs
The namespaceURI property of the created element is initialized with the value of namespaceURI. See Valid Namespace URIs. qualifiedName A string that specifies the type of element to be created. ...
... 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.getElementById("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"> <html:div> The script on this page will add dynamic conte...
... Living Standard ...
nsIMacDockSupport
source/browser/base/content/browser.js#1562 This is seen here: If you were to copy and follow that example you would replace the default native menu. ...
...e like this: var dockSupport = Cc['@mozilla.org/widget/macdocksupport;1'].getService(Ci.nsIMacDockSupport); console.log('dockSupport:', dockSupport); var win = Services.wm.getMostRecentWindow('navigator:browser'); var macMenu = win.
document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menupopup'); macMenu.setAttribute('id', 'myMacMenu'); var macMenuItem = win.
document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menuitem'); 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.getMos...
...ices.appShel.hiddenDOMWindow) loads on browser startup, so if you would like to access it on startup of the browser make sure to check and wait for the window to be loaded. This can be done by adding a event listenr for load of the hidden window. This is the recommended way to add to the native menu, just maniuplate the default menu DOM element. ...
Building accessible custom components in XUL - Archive of obsolete content
after editing, we need to explicitly restore the role attribute of the label, so that assistive technologies will continue to treat it as a cell within the spreadsheet. ...
..."textbox"); label.parentNode.replaceChild(textbox, label); textbox.value = value; textbox.origValue = value; textbox.flex = 1; textbox.focus(); textbox.select(); textbox.addEventListener("blur", editable_cell_blur, true); textbox.addEventListener("keypress", editable_cell_keypress, true); }, 0); } function done_edit(textbox, keepValue) { var value = textbox.value; var label =
document.createElementNS(XUL_NS, "label"); label.setAttributeNS(X2_NS, "role", "wairole:gridcell"); textbox.parentNode.replaceChild(label, textbox); if (keepValue) { label.value = value; } else { label.value = textbox.origValue; } label.flex = 1; label.addEventListener("keypress", cell_keypress, true); return label; } function editable_cell_blur(e) { var textbox = e.target; setT...
Dynamically modifying XUL-based user interface - Archive of obsolete content
ve the first child, until there are no children remaining. Note, that hasChildNodes() and firstChild are also part of the DOM API. var element = document.getElementById("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. It uses
document.createElementNS() method to create the items, and insertBefore() with appendChild() to insert the created xml elements within the document. Note:
document.createElementNS() creates an element, but does not put it anywhere in the document. You need to use other DOM methods, such as appendChild() to insert the newly created element in the document. appendChild() appends the node after all other nodes, while i...
...the document. You need to use other DOM methods, such as appendChild() to insert the newly created element in the document. appendChild() appends the node after all other nodes, while insertBefore() inserts the node before the node referenced by its second parameter. ...
Writing JavaScript for XHTML - Archive of obsolete content
id markup will instantly break the whole document. Solution: Use DOM Methods Many people avoided DOM methods because of the typing to create one simple element, when document.write() worked. Now you can't do this as easily as before. Use DOM methods to create all of your elements, attributes and other nodes. This is XML proof, as long as you keep the namespace problem in focus (e.g., there is a
document.createElementNS method). Of course, you can still use strings like in document.write(), but it takes a little more effort. For example: var string = '<div xmlns="http://www.w3.org/999/xhtml"><h1>Hello World!</h1></div>'; var parser = new DOMParser(); var documentFragment = parser.parseFromString(string, "text/xml"); body.appendChild(documentFragment); // assuming 'body' is the body element But be aware that ...
...o we don't want it there. ...
CustomizableUI.jsm
pe. Note: the DOM node you construct should have the same ID as the id property described above, so that CustomizableUI can find the node again later. ...
...d the node again later. ...
Browser Console - Firefox Developer Tools
the browser with the same tabs open as before the restart. Modifying the browser UI Since the global window object is the browser's chrome window, you can also modify the browser's user interface. ...
...rDocument.defaultView.
document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem"); makeTheTea.setAttribute("label", "A nice cup of tea?"); parent.appendChild(makeTheTea); On macOS, this similar code will add a new item to the "Tools" menu: var parent = window.document.getElementById("menu_ToolsPopup"); var makeTheTea = gBrowser.ownerDocument.defaultView.
document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem"); makeTheTea.setAttribute("label", "A nice cup of tea?"); parent.appendChild(makeTheTea); ...
Path2D.addPath() - Web APIs
nal A DOMMatrix to be used as the transformation matrix for the path that is added. (Technically a DOMMatrixInit object). Examples Adding a path to an existing path This example adds one path to another. HTML <canvas id="canvas"></canvas> JavaScript First, we create two separate Path2D objects, each of which contains a rectangle made using the rect() method. We then create a matrix using
document.createElementNS() and createSVGMatrix(). We then add the second path to the first using addPath(), also applying the matrix to move the second path to the right. Finally, we draw the first path (which now contains both rectangles) using fill(). const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); // Create first path and add a rectangle let p1 = new Path2D(); p1.rect(0, 0, 100...
...path (which now contains both rectangles) using fill(). const canvas = document.getElementById('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 = 1; m.b = 0; m.c = 0; m.d = 1; m.e = 200; m.f = 0; // Add second path to the first path p1.addPath(p2, m); // Draw the first path ctx.fill(p1); Result Specifications Specification Status Comment HTML Living StandardThe definition of 'Path2D.addPath()' in that specification. Living Standard Initial d...
Namespaces crash course - SVG: Scalable Vector Graphics
ever, note carefully: the Namespaces in XML 1.1 recommendation states that the namespace name for parameters without a prefix does not have a value. In other words, although the parameters belong to the namespace of the element, you do not use the tag's namespace name. Instead, you must use null as the namespace name for unqualified (prefixless) parameters. So, to create an SVG rect element using
document.createElementNS(), you must write:
document.createElementNS('http://www.w3.org/2000/svg', 'rect'); But to retrieve the value of the xparameter on an SVG rect element, you must write: rect.getAttributeNS(null, 'x'); Note that this isn't the case for parameters with a namespace prefix (parameters that don't belong to the same XML dialect as the element). Parameters such as xlink:href require the namespace name...
...easily converted back to XML (if for instance you want to send it back to the server). For example: elt.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'otherdoc.svg'); As a final example, here's a demonstration of how you should dynamically create an <image> element using script: var SVG_NS = 'http://www.w3.org/2000/svg'; var XLink_NS = 'http://www.w3.org/1999/xlink'; var image =
document.createElementNS(SVG_NS, 'image'); image.setAttributeNS(null, 'width', '100'); image.setAttributeNS(null, 'height', '100'); image.setAttributeNS(XLink_NS, 'xlink:href', 'flower.png'); Conclusion Make sure you always declare the namespaces you use in your XML files. If you don't, user agents such as Firefox won't recognize your content and will simply show the XML markup or inform the user that there's an error...
HTML to DOM - Archive of obsolete content
e HTML and return a DOM object which can be manipulated like web page elements. This will remove tags like <script>, <style>, <head>, <body>, <title>, and <iframe>. It will also remove all JavaScript, including element attributes that contain JavaScript. ...
Windows - Archive of obsolete content
dowUtils attribute currentInnerWindowID: var util = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils); var windowID = util.currentInnerWindowID; Programatically modifying HTML When attempting to modify HTML elements, it is important to specify the namespace. For example, the following code will add a horizontal rule. var hr =
document.createElementNS("http://www.w3.org/1999/xhtml", "html:hr"); document.getElementById("id1").appendChild(hr); ...
XUL Questions and Answers - Archive of obsolete content
a button that matches one of these common usages, use the icon attribute to indicate this. How to use Dynamic Objects in Toolbar There may be a few ways to implement this: By building your menupopup from an RDF datasource, which could be generated on the server. By getting data (e.g. JSON string) from the server, parsing it on client, and building the menupopup using DOM methods (such as
document.createElementNS). By getting data as XML from the server. (server can just send the XUL code to use for popup - alternatively it can send generic XML describing the attributes of the items in the menu and you generate the XUL on client by applying an XSLT transform.) Can I change a XUL tree cell/row/item background color with JavaScript? To set the background color you need to set the property for the cell...
Browser Feature Detection - Archive of obsolete content
.createCDATASection() true false true Document.createProcessingInstruction() true false true Document.createAttribute() true true true Document.createEntityReference()Obsolete since Gecko 7 true false false Document.getElementsByTagName() true true true Document.importNode() true false true
Document.createElementNS() true false true Document.createAttributeNS() true false true Document.getElementsByTagNameNS() true false true Document.getElementById() 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 Document.documentElement true true...
OS.File for the main thread
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.toFileURI, which accepts a string). After image loads it then draws it to canvas, makes it a blob, and uses FileReader to turn it into ArrayBuffer(View), then uses OS.File.writeAtomic to save to disk. ...
DOMImplementation.createDocument() - Web APIs
one. qualifiedNameStr Is a DOMString containing the qualified name, that is an optional prefix and colon plus the local root element name, of the document to be created. documentType Optional Is the DocumentType of the document to be created. It defaults to null. 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.documentElement.appendChild(body); alert(doc.getElementById('abc')); // [object HTMLBodyElement] Specifications Specification Status Comment DOMThe definition of 'DOMImplementation.createDocument' in that specification. Living Standard Modified the return type of createDocument() from Doc...
Document - Web APIs
and returns it. Document.createAttributeNS() Creates a new attribute node in a given namespace and returns it. Document.createCDATASection() Creates a new CDATA node and returns it. Document.createComment() Creates a new comment node and returns it. Document.createDocumentFragment() Creates a new document fragment. Document.createElement() Creates a new element with the given tag name.
Document.createElementNS() Creates a new element with the given tag name and namespace URI. Document.createEntityReference() Creates a new entity reference object and returns it. Document.createEvent() Creates an event object. Document.createNodeIterator() Creates a NodeIterator object. Document.createProcessingInstruction() Creates a new ProcessingInstruction object. Document.createRange() Creates a Range o...
Element.namespaceURI - Web APIs
ed on an examination of the namespace declarations in scope. The namespace URI of a node is frozen at the node creation time. In Firefox 3.5 and earlier, the namespace URI for HTML elements in HTML documents is null. In later versions, in compliance with HTML5, it is http://www.w3.org/1999/xhtml as in XHTML. You can create an element with the specified namespaceURI using the DOM Level 2 method
document.createElementNS. The DOM does not handle or enforce namespace validation per se. It is up to the DOM application to do any validation necessary. Also note that the namespace prefix, once it is associated with a particular element, cannot be changed. Specifications Specification Status Comment DOMThe definition of 'Element: namespaceURI' in that specification. Living Standard ...
Index - Web APIs
cumentFragment Creates a new empty DocumentFragment into which DOM nodes can be added to build an offscreen DOM tree. 882 Document.createElement() API, DOM, Document, Method, Reference, createElement In an HTML document, the document.createElement() method creates the HTML element specified by tagName, or an HTMLUnknownElement if tagName isn't recognized. 883
Document.createElementNS() API, DOM, Method, Reference Creates an element with the specified namespace URI and qualified name. 884 Document.createEntityReference() API, DOM, Method, Obsolete, Reference Prior to Gecko 7.0 this method showed up as present, due to bug bug 9850, it always only returned null. The only workaround is to create a text node, CDATA section, attribute node value, etc.
Node.namespaceURI - Web APIs
n time. In Firefox 3.5 and earlier, the namespace URI for HTML elements in HTML documents is null. In later versions, in compliance with HTML5, it is https://www.w3.org/1999/xhtml as in XHTML. For nodes of any Node.nodeType other than ELEMENT_NODE and ATTRIBUTE_NODE the value of namespaceURI is always null. You can create an element with the specified namespaceURI using the DOM Level 2 method
Document.createElementNS and attributes with the method Element.setAttributeNS. Per the Namespaces in XML specification, an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it has no namespace. The DOM does not handle or enforce namespace validation per se. It is up to the DOM application to do any validation necessary. Note too that the n...
Linear-gradient Generator - CSS: Cascading Style Sheets
this.angle = 0; this.state = false; this.updateOnResize(); trackMouse(rotate_point, this.updateAxisAngle.bind(this), this.startRotation.bind(this)); container.appendChild(axis); line.addEventListener('click', this.placeGradientPoint.bind(this)); }; GradientAxis.prototype.createSVGArrow = function createSVGArrow(id) { var xmlns = 'http://www.w3.org/2000/svg'; var svg =
document.createElementNS(xmlns, 'svg'); var path =
document.createElementNS(xmlns, 'path'); svg.setAttribute('class', 'gradient-arrow'); svg.setAttribute('width', '25'); svg.setAttribute('height', '25'); path.setAttribute('fill', '#CCC'); path.setAttribute('d', 'M 25,12.5 L 0,0 L 7.5,12.5 L 0,25'); svg.appendChild(path); return svg; }; GradientAxis.prototype.placeGradientPoint = function placeGradi...
Example - SVG: Scalable Vector Graphics
epel); // Add some randomness to the velocity. this.vx += Rand(3)-1; this.vy += Rand(3)-1; // Put an upper limit on velocity. this.capVelocity(); // Apply velocity. var old_x = this.x, old_y = this.y; this.x += this.vx; this.y += this.vy; this.capPosition(); // Draw it. ...
Scripting - SVG: Scalable Vector Graphics
s to go back to the previous page. The evt.preventDefault() method lets you do this. Using eventListeners with objects The methods addEventListener() and removeEventListener() are very useful when writing interactive SVG. You can pass an object that implements the handleEvent interface as the second parameter to these methods. ...
SVG In HTML Introduction - SVG: Scalable Vector Graphics
y well The picture dynamically sizes itself to the required size in an intelligent 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. Like in the following example: var img =
document.createElementNS("http://www.w3.org/2000/svg", "image"); img.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "move.png"); Details The viewBox attribute establishes a logical coordinate system which the SVG picture's coordinates are relative to. In this case our picture is laid out in a 100 by 100 viewport. The preserveAspectRatio attribute specifies that the aspect ratio must be preserved by c...