Results 1 to 2 of 2

Thread: rotating images

  1. #1
    Join Date
    Feb 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rotating images

    This is my code below. I LOVE everything about it, border and all.

    However, this only randomly changes when I reload the page.

    Is there a way I can make it so that the images keep rotating when I'm on the page instead of it randomly changing everytime I reload?

    I would like to keep the border and size and all.

    I REALLY NEED HELP!!!! THANK YOU SO MUCH IN ADVANCE!



    Code:
    <script type="text/javascript">
    /*********Edit values here for your pictures*******************/
    var 
    pic1='https://store-a32dc.mybigcommerce.com/product_images/uploaded_images/MOMSHOPPING2.gif',
    pic2='https://store-a32dc.mybigcommerce.com/product_images/uploaded_images/RRR.gif',
    pic3='https://store-a32dc.mybigcommerce.com/product_images/uploaded_images/2photos.jpg';
    /***************End of Edit*********************************/
    
    var rangPics=[pic1,pic2,pic3]; // Add all the picture variables in this array.
    window.onload=function() { rangRandom=Math.floor(Math.random()*rangPics.length);
    document.getElementById('show').innerHTML='<img src="'+rangPics[rangRandom]+'" alt="myimage" style="width:950px;height:450px;">';}</script>
    <div id="show" style="text-align:center;width:950px;border:3px double #222;padding:10px;"></div>
    Last edited by jscheuer1; 02-17-2016 at 06:22 PM. Reason: format code

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <script type="text/javascript">
    window.onload = function() {
    	/*********Edit values here for your pictures*******************/
    	var 
    	pic1='https://store-a32dc.mybigcommerce.com/product_images/uploaded_images/MOMSHOPPING2.gif',
    	pic2='https://store-a32dc.mybigcommerce.com/product_images/uploaded_images/RRR.gif',
    	pic3='https://store-a32dc.mybigcommerce.com/product_images/uploaded_images/2photos.jpg';
    
    	var rangPics = [pic1, pic2, pic3]; // Add all the picture variables to this array.
    	var pause = 3000; // milliseconds pause between images
    	
    	/***************End of Edit*********************************/
    
    	var pl, rangRandom = Math.floor(Math.random() * (pl = rangPics.length));
    	function loadpic() {
    		document.getElementById('show').innerHTML = '<img src="' + rangPics[rangRandom] + '" alt="myimage" style="width:950px;height:450px;">';
    	}
    	loadpic();
    	setInterval(function(){
    		rangRandom = ++rangRandom % pl;
    		loadpic();
    	}, pause);
    };
    </script>
    <div id="show" style="text-align:center;width:950px;border:3px double #222;padding:10px;"></div>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. rotating images (no link)
    By ksk226 in forum Looking for such a script or service
    Replies: 7
    Last Post: 06-10-2010, 08:51 AM
  2. rotating images like on Amazon.com
    By travels in forum Looking for such a script or service
    Replies: 7
    Last Post: 03-28-2008, 05:07 PM
  3. Rotating Images Script
    By kalli123 in forum Looking for such a script or service
    Replies: 1
    Last Post: 10-25-2007, 02:48 AM
  4. rotating and enlarging images
    By starry2010 in forum Other
    Replies: 2
    Last Post: 10-11-2007, 02:20 PM
  5. Rotating Images In Puzzle
    By MommaCassie in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 01-23-2006, 05:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •