Need help with random java script

1 replies
  • WEB DESIGN
  • |
Hello guys,
I am looking for a random link generator script.

Something like the Random button here - http://www.funsnap.org/.
For me it is important the script not to repeat the links. Is it even possible -

Using the Math.random does not guarantee that a link will not be repeated.

</script>
var randomlinks=new Array()

randomlinks[0]="http://freewarejava.com"
randomlinks[1]="http://javascriptkit.com"

function randomlink(){
window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
}

</script>

Any help is most appreciated.
#java #random #script
  • Profile picture of the author thememass
    If you don't want the next result is repeated, simply pop out the selected item from your array before randomizing again.
    {{ DiscussionBoard.errors[8569217].message }}

Trending Topics