Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Benoit Asselin http://www.ab-d.fr

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

insertAfter() with insertBefore() and node.nextSibling

insertAfter() with insertBefore() and node.nextSibling

Node.prototype.insertAfter = function(newNode, refNode) {
	if(refNode.nextSibling) {
		return this.insertBefore(newNode, refNode.nextSibling);
	} else {
		return this.appendChild(newNode);
	}
}


Source: Benoit Asselin

Include CSS Stylesheet by DOM


function includeCSS(p_file) {
	var v_css  = document.createElement('link');
	v_css.rel = 'stylesheet'
	v_css.type = 'text/css';
	v_css.href = p_file;
	document.getElementsByTagName('head')[0].appendChild(v_css);
}



Source: Document Object Model (DOM) Level 1 Specification

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS