Random Wallpaper

  • guest
  • Topic Author
  • Visitor
  • Visitor
12 years 7 months ago #19313 by guest
Random Wallpaper was created by guest
I love the templates I have no complaint. The random styles answer worked great, Thanks. My other question, is there a way to make the wallpaper be random also, specifically, to randomly change in the background while the page is open. Similar to the hot destinations style with it's changing background. Any thoughts or solutions on this? Thank You.

Please Log in to join the conversation.

More
12 years 7 months ago #19326 by ivan.milic
Replied by ivan.milic on topic Re: Random Wallpaper
wilt little bit modified .js from destionations:
Code:
jQuery(document).ready(function(){ var imgArr = new Array( // relative paths of images 'templates/hot_destinations/images/bg1.jpg', 'templates/hot_destinations/images/bg2.jpg', 'templates/hot_destinations/images/bg3.jpg', 'templates/hot_destinations/images/bg4.jpg' ); var preloadArr = new Array(); var i; /* preload images */ for(i=0; i < imgArr.length; i++){ preloadArr[i] = new Image(); preloadArr[i].src = imgArr[i]; } var currImg = 0; var intID = setInterval(changeImg, 10000); /* image rotator */ function changeImg(){ jQuery('#master-wrapper').animate({opacity: 0}, 2000, function(){ jQuery(this).css('background','url(' + preloadArr[Math.round(Math.random()*100) % preloadArr.length].src +') fixed center'); }).animate({opacity: 1}, 2000); } jQuery('body').css('background','url(' + preloadArr[Math.round(Math.random()*100) % preloadArr.length].src +') fixed center'); });

of course you would nee to change image paths in imgArr (you can add more) and also jQuery('#master-wrapper') should be changed to correspond to particular template master wrapper element , jQuery('body') would be univesal, background would be then set on body tag

Please Log in to join the conversation.

Time to create page: 0.145 seconds
Powered by Kunena Forum