View Full Version : Help please ASAP! In desperate need!

08-27-2004, 12:08 AM
Hi! I am making my bands website, n i though this template would make my vision easy to do..but it hasn't worked out how i'd of liked it to.


I have already put the other half of the script in, but it is this part which is wrong. It is script so that every time the home page is visited, 1 of 6 images appears at random adding variety...however, 4 of the images link to different areas of the site (this is possible?) I guess it's cause i've used HTML coding in it, but i know nothing of java.

Below is the script..if you could help me based on what I offer you, or even correct it for me, i'd be so appriciative..as i'm pulling my hair out over this.


<script language="JavaScript" type="text/javascript">
// This script was supplied free by Hypergurl
// http://www.**************
// JavaScript to interpolate random images into a page.
var ic = 6; // Number of alternative images
var xoxo = new Array(ic); // Array to hold filenames

xoxo[0] = "http://www.penitentiary.co.uk/Home%20Page%20Adverts/13th%20March%20Gig%20Edit.jpg";
xoxo[1] = "http://www.penitentiary.co.uk/Home%20Page%20Adverts/EPADlarge.jpg";
xoxo[2] = <p align="center"><a href="http://www.penitentiary.co.uk/EPcoverdesigns.htm"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/epcoverdesignAD.jpg"></a>;
xoxo[3] = <p align="center"><a href="http://www.penitentiary.co.uk/Flyers.htm"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/FlyersADlarge.jpg"></a>;
xoxo[4] = <p align="center"><a href="http://www.penitentiary.co.uk/forum/index.php"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/ForumADlarge.jpg"></a>;
xoxo[5] = <p align="center"><a href="http://www.penitentiary.co.uk/news.htm"><img src="http://www.penitentiary.co.uk/Home%20Page%20Adverts/MailinglistADlarge.jpg"></a>;

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(ic);
// -->

08-27-2004, 12:21 AM
I found this, but it says configure images to corresponding links...how do i do that?


<script language="JavaScript">

Random Image Script- By JavaScript Kit (http://www.javascriptkit.com)
Over 400+ free JavaScripts here!
Keep this notice intact please

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
document.write('<img src="'+myimages[ry]+'" border=0>')

<p align="center"><font face="arial" size="-2">This free script provided by</font><br>
<font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript

Willy Duitt
08-27-2004, 12:31 AM
Ahhh, one of HyperGirl's stolen and plagiarized scripts....
No offense, but that script is not worth fixing...

You can try my Random Image Link script...
It should be somewhat easier to use and also has the benifit of being reused several times on a page without duplicating any of the image/links...

To install, simply place the script into the HEAD of your document... Add your images and links by following the examples and where you would like a random image to appear add this script call: <script>randomLink()</script>

<script type="text/javascript">
var myNumbers = [];
function randomLink(){
var theLinks = [// ADD YOUR IMAGES AND LINKS BELOW //;
[ 'images/image0.jpg' , 'site0.html' ],
[ 'images/image1.jpg' , 'site1.html' ],
[ 'images/image2.jpg' , 'site2.html' ],
[ 'images/image3.jpg' , 'site3.html' ],
[ 'images/image4.jpg' , 'site4.html' ],
[ 'images/image5.jpg' , 'site5.html' ],
[ 'images/image6.jpg' , 'site6.html' ],
[ 'images/image7.jpg' , 'site7.html' ],
[ 'images/image8.jpg' , 'site8.html' ],
[ 'images/image9.jpg' , 'site9.html' ]

var theNumber = Math.round(Math.random()*(theLinks.length-1));
if(myNumbers.length < theLinks.length){
for(var count=0; count<myNumbers.length; count++){
while(theNumber == myNumbers[count]){
theNumber = Math.round(Math.random()*(theLinks.length-1));
count = 0;
} myNumbers.push(theNumber);

else{theNumber = 0};
var anchor = '<a class="random" href="'+theLinks[theNumber][1]+'">';
anchor+= '<img src="'+theLinks[theNumber][0]+'"></a>';



12-14-2004, 12:58 AM
I tried your code Willi and it worked great in Netscape and Safari, but not in Explorer 5.2.3. I'm coding on a mac (as I am a graphic designer), so that is the latest IE version available to me.

Is there anything I can do to this code to make it work in IE for mac?

Thanks in advance

12-14-2004, 11:43 AM
Is there anything I can do to this code to make it work in IE for mac?

ignore Mac IE, it's a POS. seriously, M$ have stopped supporting it, so why should you. IE on the Mac is so bug ridden I'm surprised the UN haven't banned it under the Biological Weapons Convention.

best thing to do is to trap its users and instruct them to use another browser.

12-14-2004, 01:31 PM
Array.push method is not supported in IE Mac. You need to add this in your page:

if(typeof Array.prototype.push=='undefined')
return this.length

For other array functionalities not fully implemented by some browsers, please refer to this (http://www.codingforums.com/showthread.php?t=19996).

08-17-2006, 02:35 PM

This is really an excellent script. I want to use it for a project of mine but I don't need the links ... just the images. What is the best way of removing the links?

Also, there is a blue border around each image. I guess this will be removed if I remove the links?

Thanks a lot. :)