File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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: 4616

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!

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: Random URL without repetition
It's not a secret anymore!