Jump to content

Recommended Posts

i have a image rotator that is working greate, but i would like to add URLs to each image that comes up. basically like a banner rotator but its not for ads lol

 

heres my code for the rotator:

//JAVASCRIPT

//Feature Rotator
var imgs = new Array ( 
'images/featured/1.png', 
'images/featured/2.png', 
'images/featured/3.png',
'images/featured/4.png'
); 
var current_img=0; 

// This is what loads the first image, seeding the rotation. 
window.onload=function() {  
if (document.getElementById('slide-show')) { 
nextimage(); 
} 
}; 

// Note setTimeout, rotates every five seconds 
// when the end of the list is reached, starts over. 
function nextimage() { 
document.getElementById('slide-show').style.background= 
"url("+imgs[current_img]+") top left no-repeat"; 
current_img=((current_img+1)>(imgs.length-1))?0:current_img+1; 
setTimeout('nextimage()',5000); 
} 

//DISPLAY CODE

<table width="750" height="300" border="0" cellpadding="0" cellspacing="0">
    <tr>

    //the ID tag is where the JS gets drawn too
     <td id="slide-show" background="images/featured/1.png" valign="top"><img src="images/featured.png" />
     <center>

        </center>
     </td>
    </tr>
   </table>

Link to comment
https://forums.phpfreaks.com/topic/253770-image-rotator-with-urls-help/
Share on other sites

I'm not going to write the code for you but just give a you a start. Instead of using a simple array, use a multidimensional array. eg;

 

var imgs = [ 
    ['images/featured/1.png', 'http://somedomain.com'], 
    ['images/featured/2.png',  'http://somedomain.com'],
    ['images/featured/3.png', 'http://somedomain.com'],
    ['images/featured/4.png' 'http://somedomain.com']
];

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.