Un código muy simplón para eliminar todos los hijos de un nodo sin que pueda dar ningún tipo de fallo:
var container = document.getElementById('id_del_nodo');
while (container.hasChildNodes()){
container.removeChild(container.lastChild);
}
No hay nada más fecundo que la ignorancia consciente de sí misma.
-- J. Ortega y Gasset
var container = document.getElementById('id_del_nodo');
while (container.hasChildNodes()){
container.removeChild(container.lastChild);
}
function getDataFromServer(queryString,callbackFunctionName){
XMLHttpRequestObject.open('POST', '/mi/url', true);
XMLHttpRequestObject.onreadystatechange = callbackFunctionName;
XMLHttpRequestObject.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded;charset=UTF-8");
XMLHttpRequestObject.send(queryString);
}
function getXMLHttpRequestObject(){
if (window.XMLHttpRequest)
{
//El explorador implementa el interfaz de forma nativa
return new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
//El explorador permite crear objetos ActiveX
try {
return new ActiveXObject("MSXML2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
alert('XMLHttpRequest no disponible');
}
var imgCuerpo = document.createElement('img');
imgCuerpo.style.width = '739px';
imgCuerpo.style.height = '375px';
cuerpo.insertBefore(imgCuerpo,cuerpo.childNodes[0]);
imgCuerpo.src = '/path/to/img.png';
document.getElementById('contenedor').appendChild(nuevoElemento);
var contenedor = document.getElementById('contenedor');
var hijo = contenedor.childNodes[0];
var nuevoElemento = document.createElement('div');
contenedor.insertBefore(nuevoElemento, hijo);
height: 1%que se convertirá en
height: autosalvo que el parent tenga una height propia.
<!--[if lt IE 7]><style>
/* style for IE6 + IE5.5 + IE5.0 */
.gainlayout { height: 0; }
</style><![endif]-->
<!--[if gte IE 7]><style>
.gainlayout { zoom: 1; }
</style><![endif]-->
var d= document.createElement("div"); d.className= 'miEstilo'; d.innerHTML= 'Contenido'; document.getElementsByTagName("body")[0].appendChild(d);
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7896
xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn"
<xsl:variable name="set" select="dyn:evaluate($selector)"/>
xmlns:dateparser="xalan://java.text.SimpleDateFormat" extension-element-prefixes="dateparser"
<xsl:variable name="dateformatter" select="dateparser:new('yyyyMMdd')"/>
<xsl:value-of select="dateparser:format($dateformatter,$date)/>
^(ftp|http|https)?:?(//)?[a-zA-Z0-9@\\.]*\\.[a-zA-Z0-9@\\.]*:?[0-9]*/
var s = document.createElement("script"); s.src = 'script-location/script-name.js'; s.type="text/javascript"; document.getElementsByTagName("head")[0].appendChild(s);Este código lo carga al final del head.
<a href='location' onclick='cargaScript()'>cargar</a>
if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.mouseover){ document.getElementById('anchor').mouseover=function(){ var evt = this.ownerDocument.createEvent('MouseEvents'); evt.initMouseEvent('mouseover', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt); } } else{ document.getElementById('anchor').mouseover = function(){ this.fireEvent('onmouseover'); } }