Random Images

  • 1
  • Question
  • Updated 9 years ago
  • Answered
whats the HTML code for 4 random images?
i have the images i just want them to be sistplayed randomly.

thanks

alex
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
  • amused

Posted 9 years ago

  • 1
Photo of Shaq

Shaq

  • 868 Posts
  • 5 Reply Likes
Code like this can be really bad for your site and make it not funcation well esp with mouse overs (experience)

use slide, i think its a safer and best bet
slide.com
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
please can i have the code lee?
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
ok this post is to Alex - Anyone else reading it use this with caution.

ALWAYS USE A TEST PAGE

FOUND ISSUES: if you add this code to a text widget sometimes Yola editor will try to add aN extra image file under the javascript.
(Alex if this happens to you i will show you how to easily delete the extra unwanted code-or add it in a html widget instead)

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

function random_imglink(){
var myimages=new Array()

myimages[1]="resources/places.jpg"
myimages[2]="resources/places2.jpg"
myimages[3]="resources/places3.jpg"
myimages[4]="resources/places4.jpg"

var imagelinks=new Array()
imagelinks[1]="http://hexham.info/places"
imagelinks[2]="http://hexham.info/places"
imagelinks[3]="http://hexham.info/places"
imagelinks[4]="http://hexham.info/places"

var ry=Math.floor(Math.random()*myimages.length)

if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border="0" style="border: medium none ; width: 189px; height: 144px;" title="ADDYOURTITLE" alt="ADD YOUR ALT TEXT"></a>')
}

random_imglink()

</script>

-->

This is the best script i have found for randomly showing images.

## Just change the myimages to a file in your file manager and change the image links to whatever you like - imagelink[1] is the link for myimage[1]

Add more images just add another line [5]

Easy - Enjoy

Lee.
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
tee hee, i am fast,
i will change it
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
it dosnt work, it always says javascript error
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
alex for some reason when you copy it from this page it screws it up - Copy it - then run it through notepad - then apply it to the page --- this will work i just tested it. Lee
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
it still wont work in notepad.
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
if it strips text of unwanted code yes - in windows its notepad built in, i dont know what wordpad is but it sounds like its the same thing.,
Photo of Alex

Alex

  • 3448 Posts
  • 39 Reply Likes
well lee, i cant get the random image code to work.
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
what image address are you using? -- paste the code you edited back here and i will take a look.