Results 1 to 7 of 7

Thread: Random Link script anywhere?

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Link script anywhere?

    Random Link script anywhere?
    http://www.misssparkle.com/2006/jokes/wj1.html

    My question is about making a link that, to the viewer, reads "Previous Jokes" but when they click on it, it could take them to any one of the previous jokes pages I have set up.

    Thanks in advance!

    e

  2. #2
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This post will proberly get moved because it is not related to DD scripts until its moved i will not help you, sorry. You should read the rules

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, there are random content scripts here at DD so, I guess this qualifies somewhat. You might want to look at the random iframe content script.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK im guessing you will have the URL to the sites with the jokes on. So you could create a function that generates a number then choses a site.

    Code:
    <html>
    <head>
    <script language="javascript">
    <!--
    function joke()
    {
    	x = Math.random()
    	x = x * 100
    	x = Math.round(x)
    	
    	if (x < 10)
    	{
    		window.location = "http://www.myjoke.com"
    	}
    	if (x < 20 && x > 10)
    	{
    		window.location = "http://www.myjoke2.com"
    	}
    	if (x < 30 && x > 20)
    	{
    		window.location = "http://www.myjoke3.com"
    	}
    	if (x < 40 && x > 30)
    	{
    		window.location = "http://www.myjoke4.com"
    	}
    }
    
    </script>
    </head>
    <body>
    <a href="#" onmouseup='joke()'>Previous Jokes</a>
    </body>
    </html>
    althought not the best code at all it works quite well.

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    if x= 10, 20 , or 30 you're out of luck. You could change from > to >= in the && part of the conditionals. or decrement the values by 1 in that part, ex:

    Code:
    if (x < 20 && x >= 10)
    or:

    Code:
    if (x < 20 && x > 9)
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ow yea silly me lol at least you spotted it, i tested the code many times but always worked lol guess i was lucky

  7. #7
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default Random Background Images

    Can the script you're talking about http://www.dynamicdrive.com/dynamici...ndomiframe.htm easily be adapted to select a random background image, with associated transparancy applied for each image? (Alas, the images that were given to me vary in darkness, and I have to add a bit of text - image credit - somewhere in the page.) This is something I've been needing to do and putting off and the other DD random script I've been thrashing with http://www.dynamicdrive.com/dynamici...tentcolors.htm just isn't going to get me there. Any chance for a helping start? Your expert advice would really be appreaciated. Thanks.

    strangeplant

Bookmarks

Posting Permissions

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