Old code: CSS rules on the fly from JavaScript (2006)

Again, some old code I'm not using anymore since I switched to jQuery but that might be useful for someone:

 * Public Domain
 * Created by Toni Corvera <outlyer@outlyer.net> in September, 2006
 * Creates a new CSS ruleset, should work with multiple rules correctly
 * e.g.:
 *    loadCssRules('body{font-family:sans-serif;}a:link{color:red;}');
// void function loadCssRules(String rules)
function loadCssRules(r) {
	if (!document.createElement) return;
	var newStyle=document.createElement('STYLE');
	newStyle.setAttribute('type', 'text/css');

Downloadable file: http://p.outlyer.net/graveyard/net_outlyer_dyn_css.js

Discover more from OutlyerNet

Subscribe to get the latest posts to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top