We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

Roshambo on 10/03/06


Tagged

css random stylesheet


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

leitmotiv
Hirmine


Load Random Stylesheets


Published in: JavaScript 


  1. // Loads a stylesheet at random. Pass each stylesheet as an argument.
  2. function loadRandomStylesheets(stylesheets)
  3. {
  4. if(arguments.length < 1) return false;
  5. var url = arguments[Math.round(Math.random() * (arguments.length - 1))];
  6. var html = '<style type="text/css">\
  7. @import url(' + url + ');\
  8. </style>';
  9. document.write(html);
  10. return true;
  11. }

Report this snippet 

You need to login to post a comment.