View Single Post
Old 01-17-2013, 10:25 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,549
Thanks: 62
Thanked 4,054 Times in 4,023 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Your script should have worked. Well, except it would do it to all pages, no matter what the initial class name.

But only if you put it *AFTER* the </body> tag in your page.

Try this:
Code:
</body>
<script type="text/javascript">
var cn = document.body.className;
if ( cn.indexOf("templateCollection") >= 0 || cn.indexOf("templateProduct") >= 0 )
{
    document.body.className+=' randomizeBackground';
}
</script>
</html>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
ajhauser (01-18-2013)