Thanks it works great!!
On Tue, 25 May 2004 18:12:40 GMT, Grant Wagner
<gwagner@agricoreunited.com> wrote:
[color=blue]
> Olly wrote:
>[color=green]
>> I've found a basic script, however I also need to add alt and title
>> attributes as well, how would I go about doing this?
>>
>> Here's the script I found:
>> Thanks
>>
>> <script language="JavaScript">[/color]
>
> <script type="text/javascript">
>[color=green]
>> <!--[/color]
>
> Not needed.
>[color=green]
>> /*
>> Random Image Link Script- By JavaScript
>> Kit(
http://www.javascriptkit.com)
>> Over 200+ free JavaScripts here!
>> Updated: 00/04/25
>> */
>>
>> function random_imglink(){
>> var myimages=new Array()
>> //specify random images below. You can have as many as you wish
>> myimages[1]="../images/s01.jpg"
>> myimages[2]="../images/s02.jpg"
>> myimages[3]="../images/s03.jpg"
>> myimages[4]="../images/s04.jpg"
>> myimages[5]="../images/s05.jpg"
>> myimages[6]="../images/s06.jpg"[/color]
>
> Arrays start at 0 in Javascript, by starting at 1, the author of this
> script
> ended up using a hack at the later that results in the first image
> appearing
> more often then the rest.
>
> var myimages = [
> "../images/s01.jpg",
> "../images/s02.jpg",
> "../images/s03.jpg",
> "../images/s04.jpg",
> "../images/s05.jpg",
> "../images/s06.jpg"
> ];
>[color=green]
>> //specify corresponding links below
>> var imagelinks=new Array()
>> imagelinks[1]="../photos/01.html"
>> imagelinks[2]="../photos/02.html"
>> imagelinks[3]="../photos/03.html"
>> imagelinks[4]="../photos/04.html"
>> imagelinks[5]="../photos/05.html"
>> imagelinks[6]="../photos/06.html"[/color]
>
> var imagelinks = [
> "../photos/01.html",
> "../photos/02.html",
> "../photos/03.html",
> "../photos/04.html",
> "../photos/05.html",
> "../photos/06.html"
> ];
>
> New code:
>
> var imagealts = [
> "alt text 1",
> "alt text 2",
> "alt text 3",
> "alt text 4",
> "alt text 5",
> "alt text 6"
> ];
>
> var imagetitles = [
> "image title 1",
> "image title 2",
> "image title 3",
> "image title 4",
> "image title 5",
> "image title 6"
> ];
>[color=green]
>> var ry=Math.floor(Math.random()*myimages.length)
>> if (ry==0)
>> ry=1[/color]
>
> Replace this all with:
>
> var img = Math.floor(myimages.length * Math.random());
>[color=green]
>> document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img
>> src="'+myimages[ry]+'" border=0></a>')
>> }[/color]
>
> document.write(
> '<a href="' + imagelinks[img] + '"><img src="' +
> myimages[img] + '" border="0" alt="' +
> imagealts[img] + '" title="' +
> imagetitles[img] + '"></a>'
> );
>[color=green]
>> random_imglink()[/color]
>
> I have no idea what this does. You don't have the function
> random_imglink()
> defined in the code you showed us. Perhaps the document.write() was once
> done
> in "random_imglink()"? If so, you're now doing the document.write() as
> inline
> Javascript, the function call is no longer required.
>[color=green]
>> //-->[/color]
>
> Not needed.
>[color=green]
>> </script>
>>
>> --
>> Olly
>>
>> Using Opera's revolutionary e-mail client:
http://www.opera.com/m2/[/color]
>
> --
> | Grant Wagner <gwagner@agricoreunited.com>
>
> * Client-side Javascript and Netscape 4 DOM Reference available at:
> *
>
http://devedge.netscape.com/library/...ce/frames.html
>
> * Internet Explorer DOM Reference available at:
> *
>
http://msdn.microsoft.com/workshop/a...ence_entry.asp
>
> * Netscape 6/7 DOM Reference available at:
> *
http://www.mozilla.org/docs/dom/domref/
> * Tips for upgrading JavaScript for Netscape 7 / Mozilla
> *
http://www.mozilla.org/docs/web-deve...upgrade_2.html
>
>[/color]
--
Olly
Using Opera's revolutionary e-mail client:
http://www.opera.com/m2/