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

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Random URL without repetition" Watch "Random URL without repetition" New topic

Random URL without repetition

Alice Poe

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()

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

Joined: Sep 20, 2010
Posts: 3679

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:
subject: Random URL without repetition