Hi All,
Anybody knows how to create URL randomly?
For example: I have 10 different websites. How do I link this 10 websites to a single URL and whenever someone visits this URL it will appear randomly?
Thanks
Printable View
Hi All,
Anybody knows how to create URL randomly?
For example: I have 10 different websites. How do I link this 10 websites to a single URL and whenever someone visits this URL it will appear randomly?
Thanks
Use javascript... create an array with the URLs of all the websites... then either grab the time and use the seconds as a random number generator or I believe there is a random number generator with JS. Or why not just have a drop-down box with all the sites in it?
/edit - check here for something that may help you.
Well, don't look at the code, I did it in 3 minutes
I don't know if it is this what you want... I tested it with the following code:Code:<script language="JavaScript">
function prRndUrl() {
var arr = new Array(10);
var rnd = Math.floor(Math.random()*10) //generate random
arr[0] = "http://www.cnn.com";
arr[1] = "http://www.bbc.com";
arr[2] = "http://www.cprogramming";
arr[3] = "http://www.oscar.com";
arr[4] = "http://www.java.sun.com";
arr[5] = "http://www.linux.org";
arr[6] = "http://www.mandrake.org";
arr[7] = "http://www.slackware.org";
arr[8] = "http://www.suse.org";
arr[9] = "http://www.microsoft.com";
document.write("Hello our random site today is: " + arr[rnd] + " enjoy");
window.open(arr[rnd],'Random','width=500,height=500');
}
</script>
Code:<html>
<head>
<title>Testing</title>
<script language="JavaScript">
function prRndUrl() {
var arr = new Array(10);
var rnd = Math.floor(Math.random()*10) //generate random
arr[0] = "http://www.cnn.com";
arr[1] = "http://www.bbc.com";
arr[2] = "http://www.cprogramming";
arr[3] = "http://www.oscar.com";
arr[4] = "http://www.java.sun.com";
arr[5] = "http://www.linux.org";
arr[6] = "http://www.mandrake.org";
arr[7] = "http://www.slackware.org";
arr[8] = "http://www.suse.org";
arr[9] = "http://www.microsoft.com";
document.write("Hello our random site today is: " + arr[rnd] + " enjoy");
window.open(arr[rnd],'Random','width=500,height=500');
}
</script>
</head>
<body onLoad="prRndUrl()">
</body>
</html>
Hi,
Yep, thats what I was looking for. Thanks alot guys!