Random Background - Joomla! Forum - community, help and support
dear all,
i've been looking how have on site random background like:http://www.theroadlesstraveled.com
the directions have been given are:
i did try doesn't work reason. i'm using template rt dimensions light.
it appreciated if let me know how can implement on site. sadly no have live site yet, on local pc.
thanks,
s
i've been looking how have on site random background like:http://www.theroadlesstraveled.com
the directions have been given are:
i have random background on of pages, , specific background on others. here how did random background:
place code within first section of php in template index.php file:
$imgid = sprintf("_%02d",rand(1,10));
this creates random background image call. number 10 refers how many images select random background.
then after closing head tag of same index.php file, place code:
<body background="/images/backgrounds/image<?php echo $imgid; ?>.jpg" style="background-repeat: no-repeat;">
my background images located in images/backgrounds/image_01.jpg
all of image files named image_01.jpg through image_10.jpg
this may need adjusted bit work replicant v2 template, same principal should work.
let me know if works you!
i did try doesn't work reason. i'm using template rt dimensions light.
it appreciated if let me know how can implement on site. sadly no have live site yet, on local pc.
thanks,
s
i add "invisible" module @ bottom, let footer js, generates random number. number whould used change body background image via css.
<script>
math.randommax = function(maxval,asfloat){
var val = math.random()*maxval;
return asfloat?val:math.round(val);
}
var = math.randommax(10);
document.write('<style>body {background-image:url(/path/to/image'+i+'.jpg);'}</style>');
</script>
for case have prepare image0.jpg through image10.jpg of course.
<script>
math.randommax = function(maxval,asfloat){
var val = math.random()*maxval;
return asfloat?val:math.round(val);
}
var = math.randommax(10);
document.write('<style>body {background-image:url(/path/to/image'+i+'.jpg);'}</style>');
</script>
for case have prepare image0.jpg through image10.jpg of course.
Comments
Post a Comment