Searching for a Java Script...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Unhinged
    Registered User
    • Jul 2002
    • 67

    #1

    Searching for a Java Script...

    ...that I could use to rotate active text links. i.e. I would like to have a script that I could add 5 or 6 different URLs and have the URL be random each time it's clicked. I have seen similiar scripts but only in the way of forms. I want this to be used with text links. Can anyone help me locate this?

    Thanks in advance
    118862017
    [email protected]
  • PornAddict
    Confirmed User
    • Feb 2002
    • 1401

    #2
    Check out http://javascript.internet.com
    They have lots of useful scripts.

    - PornAddict

    Comment

    • Unhinged
      Registered User
      • Jul 2002
      • 67

      #3
      thanks for that link but I couldnt find what I need. I appreciate the effort though. THANKS!
      118862017
      [email protected]

      Comment

      • PhilipX
        Confirmed User
        • Aug 2002
        • 200

        #4
        Just copy paste this script in a blank HTML page. Hope this the thing you wanted.
        ----------------------------------------------------------------------------

        <script >
        <!--

        //specify random links below. You can have as many as you want
        var randomlinks=new Array()

        randomlinks[0]="http://freewarejava.com"
        randomlinks[1]="http://wsabstract.com"
        randomlinks[2]="http://dynamicdrive.com"
        randomlinks[3]="http://cnn.com"
        randomlinks[4]="http://www.geocities.com"

        function randomlink(){
        window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
        }
        //-->
        </script>
        <form>
        <p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()"></p> </form>

        Comment

        • Unhinged
          Registered User
          • Jul 2002
          • 67

          #5
          combscombs-

          Thats similiar to what Im looking for but I dont want the button. I just want it as simple text links. I found that script before and dicked with it for awhile but couldnt make it work as a simple text link.

          Thanks for your help though. Its much appreciated!
          118862017
          [email protected]

          Comment

          • KevinG
            Registered User
            • Sep 2002
            • 10

            #6
            Sometimes the obvious stares us in the face

            PHP Code:
            <a href="#" onclick="randomlink();">click here</a> 
            

            Comment

            • Unhinged
              Registered User
              • Jul 2002
              • 67

              #7
              Kevin, I appreciate your taking the time to respond but I'm afraid that just isnt enough info for me....lol

              What is the script I add in the < head > tags and where do I add all the random links?

              Im a java idiot, please explain it in more detail

              thanks
              118862017
              [email protected]

              Comment

              • KevinG
                Registered User
                • Sep 2002
                • 10

                #8
                As taken from combscombs post the following goes into the head section

                PHP Code:
                <script >
                <!--
                
                //specify random links below. You can have as many as you want
                var randomlinks=new Array()
                
                randomlinks[0]="http://freewarejava.com"
                randomlinks[1]="http://wsabstract.com"
                randomlinks[2]="http://dynamicdrive.com"
                randomlinks[3]="http://cnn.com"
                randomlinks[4]="http://www.geocities.com"
                
                function randomlink(){
                window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)]
                }
                //-->
                </script> 
                
                You can then use the code I posted last time anywhere on the html file

                PHP Code:
                <a href="#" onclick="randomlink();">click here</a> 
                

                Regards,
                Kevin

                P.S. Sorry about the delay in replying hard drive failure earlier today so spent the whole day recovering data

                Comment

                • Unhinged
                  Registered User
                  • Jul 2002
                  • 67

                  #9
                  I added the script as you said and it no worky worky. It just refreshes my page but thanks anyway.
                  118862017
                  [email protected]

                  Comment

                  • KevinG
                    Registered User
                    • Sep 2002
                    • 10

                    #10
                    Unhinged, it worked on my browser...you may want to try replacing the # in the link with javascript:void(null)

                    Regards,
                    Kevin

                    Comment

                    • Unhinged
                      Registered User
                      • Jul 2002
                      • 67

                      #11
                      I tried replacing that as well and still no work. Oh well, thanks anyway man, I really appreciate it
                      118862017
                      [email protected]

                      Comment

                      • mijoon
                        Confirmed User
                        • Apr 2002
                        • 610

                        #12
                        Hi unhinged,
                        Click http://rabbitsgirls.com/linkRotater.htm . I think this is what you're looking for.

                        Comment

                        Working...