...

View Full Version : modification of "Super Random Link Generator"



avalonx
03-01-2003, 02:04 AM
I really like the "Super Random Link Generator" from javascriptkit.com, because you don't need an array of links, which is annoying if you have 300 links on a page, changing frequently.



<script>
<!--
/*Super random link script- Written by JavaScript Kit
(www.javascriptkit.com) over 200+ free JavaScripts here!
*/
function random_all(){
var myrandom=Math.round(Math.random()*(document.links.length-1))
window.location=document.links[myrandom].href
}
//-->
</script>


I'd like to modify this script so that only links with the ending *.php are chosen. How could this be done?

joh6nn
03-01-2003, 04:46 AM
try this:

<script>
<!--
/*Super random link script- Written by JavaScript Kit
(www.javascriptkit.com) over 200+ free JavaScripts here!
*/
function random_all(){
var myrandom=Math.round(Math.random()*(document.links.length-1))
if (document.links[myrandom].href.indexOf('.php') >= 0) {
window.location=document.links[myrandom].href;
}
}
//-->
</script>

Kamiju
07-11-2003, 02:17 PM
I too like the "Super Random Link Generator" a lot, but would like to know if it is possible to us it in another way.

I want to use an external linkpage to generate a random link in eg. my links page, can that be done with "SRLG" ?
If not, please guide me to another code :-)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum