renovations
This commit is contained in:
parent
a6431c3f97
commit
dce565963b
115 changed files with 1433 additions and 1563 deletions
35
2-ui/1-document/12-multi-insert/insertAdjacentFF.js
Normal file
35
2-ui/1-document/12-multi-insert/insertAdjacentFF.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
// http://learn.javascript.ru/files/tutorial/browser/dom/insertAdjacentFF.js
|
||||
// Добавляет поддержку insertAdjacent* в Firefox
|
||||
|
||||
if (typeof HTMLElement != "undefined" && !HTMLElement.prototype.insertAdjacentElement) {
|
||||
HTMLElement.prototype.insertAdjacentElement = function(where, parsedNode) {
|
||||
switch(where) {
|
||||
case 'beforeBegin':
|
||||
this.parentNode.insertBefore(parsedNode, this)
|
||||
break;
|
||||
case 'afterBegin':
|
||||
this.insertBefore(parsedNode, this.firstChild);
|
||||
break;
|
||||
case 'beforeEnd':
|
||||
this.appendChild(parsedNode);
|
||||
break;
|
||||
case 'afterEnd':
|
||||
if(this.nextSibling) this.parentNode.insertBefore(parsedNode, this.nextSibling);
|
||||
else this.parentNode.appendChild(parsedNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HTMLElement.prototype.insertAdjacentHTML = function(where, htmlStr) {
|
||||
var r = this.ownerDocument.createRange();
|
||||
r.setStartBefore(this);
|
||||
var parsedHTML = r.createContextualFragment(htmlStr);
|
||||
this.insertAdjacentElement(where, parsedHTML)
|
||||
}
|
||||
|
||||
|
||||
HTMLElement.prototype.insertAdjacentText = function(where, txtStr) {
|
||||
var parsedText = document.createTextNode(txtStr)
|
||||
this.insertAdjacentElement(where, parsedText)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue