Red de conocimiento informático - Material del sitio web - Cómo crear dinámicamente etiquetas de enlace en el encabezado usando JavaScript

Cómo crear dinámicamente etiquetas de enlace en el encabezado usando JavaScript

lt;!doctype?htmlgt;

lt;htmlgt;

lt;headgt;

lt;titlegt;create?a?linklt;/titlegt;

lt;script?type="text/javascript"gt;

onload?=?function(){ var?link?=?document.createElement('enlace');

link.setAttribute('tipo', 'texto/css');

link.setAttribute('rel', 'hoja de estilo');

enlace. setAttribute('href', '/bootstrap/3.3.6/css/bootstrap.min.css');

document.head.appendChild(enlace);

}

}

p>

lt;/scriptgt;

lt;/headgt;

lt;bodygt;

lt;p?class=" text-primary "gt; Este es un párrafo, el estilo se crea dinámicamente con referencia a bootstraplt;/pgt;

lt;/bodygt;

lt;/htmlgt;