Need help with random java script

by 1 replies
1
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.
#website design #java #random #script
  • If you don't want the next result is repeated, simply pop out the selected item from your array before randomizing again.

Next Topics on Trending Feed