Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design Load random CSS on page load Reply To: Load random CSS on page load

#247699
Shikkediel
Participant

Continuing on Beverley’s example, here’s how you would do it with JS:

<head>
<script>
(function() {
var sheet = document.createElement('link');
sheet.rel  = 'stylesheet';
sheet.href = '/path/to/styles/' + (Math.floor(Math.random()*5)+1) + '.css';
document.getElementsByTagName('head')[0].appendChild(sheet);
})();
</script>
</head>