View Full Version : Random Link script anywhere?
bsheets
03-27-2006, 01:33 PM
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
.alias.
03-27-2006, 02:41 PM
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
jscheuer1
03-27-2006, 04:35 PM
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 (http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm).
.alias.
03-27-2006, 05:04 PM
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.
<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.
jscheuer1
03-27-2006, 05:58 PM
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:
if (x < 20 && x >= 10)
or:
if (x < 20 && x > 9)
.alias.
03-27-2006, 06:17 PM
:p ow yea silly me lol at least you spotted it, i tested the code many times but always worked lol guess i was lucky
Strangeplant
03-28-2006, 03:03 PM
Can the script you're talking about http://www.dynamicdrive.com/dynamicindex17/randomiframe.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/dynamicindex17/contentcolors.htm just isn't going to get me there. Any chance for a helping start? Your expert advice would really be appreaciated. Thanks.
strangeplant
Powered by vBulletin® Version 4.2.2 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.