File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 Android Security Essentials Live Lessons this week in the Android forum!
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: 3602
    
  14

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!
 
 
subject: Random URL without repetition
 
Similar Threads
problem when integrating jspell with tinyMCE editor
I want create UI desing in jsp using html and javascript
change CSS rules dynamic with JavaScript
how to design this JSP. need ur suggestion
Display information related to that link