Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    modification of "Super Random Link Generator"

    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?

  • #2
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    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>
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #3
    New to the CF scene
    Join Date
    Jul 2003
    Location
    Denmark
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Another modification ?

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •