With Joomla, or any CMS, even simply with a PHP supporting host, you can set a server side cookie in the user's profile. I won't go into that, as it isn't my area of expertise, but it would probably be the best method.
Using javascript, you can add these quirksmode.org cookie functions to the page (in the head in either a script bock or as an external script):
Code:
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
Then when you set the bg, also set the cookie:
HTML Code:
<img src="thumb1.jpg" alt="Background Thumnail" title="whatever"
onclick="document.getElementById('banner_bg').style.backgroundImage='url(bg1.jpg)';
createCookie('banner_bg','bg1.jpg',50);">
50 will be the number of days persistence. Then, where you have this markup:
HTML Code:
<div id="banner_bg">
<a href="<?php echo $mosConfig_live_site;?>" title=""><span id="logo"> </span></a>
</div>
Add to it:
HTML Code:
<div id="banner_bg">
<a href="<?php echo $mosConfig_live_site;?>" title=""><span id="logo"> </span></a>
</div>
<script type="text/javascript">
;(function(){
var bg=readCookie('banner_bg')? readCookie('banner_bg') : 'some.jpg';
document.getElementById('banner_bg').style.backgroundImage='url('+bg+')';
})();
</script>
some.jpg is the default background image.
Bookmarks