aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Random URL without repetition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Random URL without repetition" Watch "Random URL without repetition" New topic
Author

Random URL without repetition

Alice Poe
Greenhorn

Joined: Apr 22, 2014
Posts: 1
Hey, I have so little java knowledge and I need to use it for my thesis.
I have three websites and I want to randomly generate them. First one works perfectly fine with

<script type="text/javascript">
function randomlinks(){
var myrandom=Math.round(Math.random()*2)
var links=new Array()
links[0]="link1"
links[1]="link2"
links[2]="link3"


window.open(links[myrandom]);
}
</script>

Once one of them is generated, I don't want it to repeat itself.
I have searched a lot, but I do not seem to get a clear answer or I simply do not understand so technical language.
Any help would be appreciated. Thanks in advanced.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3646
    
  16

The solution would be to remove that link from your array after you've opened it. Take a look at the splice() method.

By the way, did you know that JavaScript and Java are two completely unrelated languages? I'm going to move this to the JavaScript forum.

Welcome to CodeRanch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Random URL without repetition