Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

linking rotating images

align

  • Please log in to reply
3 replies to this topic

#1 dowdy

dowdy

    CC Newcomer

  • Just Joined
  • PipPip
  • 12 posts

Posted 13 December 2008 - 10:06 AM

Hi, quick question.
I tried to figure it out myself be couldn't. I have a image rotating code on my site, but i want to be able to link each image to an article (Each random image is a image interdiction for a article)

He is the header code for the image rotating


<script language="JavaScript">
<!--
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array. Rememeber
// to increment the theImages[x] index!

theImages[0] = 'images/rotate/1.jpg'
theImages[1] = 'images/rotate/2.jpg'
theImages[2] = 'images/rotate/3.jpg'
theImages[3] = 'images/rotate/4.jpg'
theImages[4] = 'images/rotate/5.jpg'


var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}

//-->

And here is how i display the code in my index.html

<p align="center"><script language="JavaScript">
<!--
showImage();
//-->
</script></span

Any help would be great, thanks
  • 0

#2 moonknight

moonknight

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 86 posts

Posted 15 January 2009 - 02:08 PM

maybe start and end the tag in the header and start it in the body?

im not good with js
  • 0
programming is like s*x................................one mistake an you have to support it the rest of your life

#3 jhonichen

jhonichen

    CC Newcomer

  • Just Joined
  • PipPip
  • 20 posts

Posted 11 May 2009 - 08:56 AM

try to put the href into another JScript array
<script language="JavaScript">
<!--
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array. Rememeber
// to increment the theImages[x] index!

theImages[0] = 'images/rotate/1.jpg'
theImagesLink[0] = 'http : / / www[dot]rotate1[dot]com'
theImages[1] = 'images/rotate/2.jpg'
theImagesLink[1] = 'http : / / www[dot]rotate2[dot]com'
theImages[2] = 'images/rotate/3.jpg'
theImagesLink[2] = 'http : / / www[dot]rotate3[dot]com'
theImages[3] = 'images/rotate/4.jpg'
theImagesLink[3] = 'http : / / www[dot]rotate4[dot]com'
theImages[4] = 'images/rotate/5.jpg'
theImagesLink[4] = 'http : / / www[dot]rotate5[dot]com'


var j = 0
var p = theImages.length;

var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}

var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<a href="' + theImagesLink[whichImage] + '">< i m g src="'+theImages[whichImage]+'" border="0"></a>');
}

//-->

  • 0

#4 hkp

hkp

    CC Regular

  • Just Joined
  • PipPipPip
  • 36 posts

Posted 28 May 2009 - 09:46 PM

Try it hope this is very useful for you..

Step 1: place the code below between the < BODY > and tags within the HTML page where you want the random banners to appear.

<ilayer id="l1">
    <layer id="l2">
        <div id="l1">
            <div id="l3" style="position:relative">
            </div>
        </div>
    </layer>
</ilayer>

Step 2: place this code below the above code. the best place would be right before the tag.

<script language="JavaScript">
<!--

var bannerArray = new Array();
var myCount=0;
// Banner Code Assignment
bannerArray[0] = "<A HREF=\"http://your link here\"><IMG SRC=\"http://image 1 path link here\" border=\"0\" width=\"468\" height=\"60\"></A>";
bannerArray[1] = "<A HREF=\"http://your link here\"><IMG SRC=\"http://image 2 path link here\" border=\"0\" width=\"468\" height=\"60\"></A>";
bannerArray[2] = "<A HREF=\"http://your link here"><IMG SRC=\"http://image 3 path link here" border=\"0\" width=\"468\" height=\"60\"></A>";

bannerRotate();

___________________
Design a website
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download