a DIFFERENT random than what anybody else wants!
All the "random" pix scripts I see are essentially the same.
What I want is ... I'll explain it linearly:
a) I have a word on the page.
b) I make a link out of it (javascript:;)
c) user clicks
d) a new page opens correctly sized to an image.
e) the images are chosen at random from some pix in a subdirectory.
There might be 2 pix or 30. They might be different but appropriate sizes: 400 x 320, or 525 x 405 px, etc etc.
DESIRED RESULT: everytime someone clicks on what looks like a 'standard' link a window opens with a different picture.
Whew!
Thanks,
The Soundoctor
Ok, well that was a lame first post
This should work.
Code:
<!-- your links-->
<a href="Javascript:chooseRandomPic()">Random Picture Link</a>
<!-- img used to get width and height dynamically-->
<img id="testSize" src="" style="visibility:hidden; position:absolute; top:-10000; left:-10000;">
<script>
picArray = new Array("blog.png","pic2.gif","pic3.jpg") //All pics you wan to include
subDirectory = "images/" //subdirectory of images to use
function chooseRandomPic()
{
openWindow(picArray[Math.floor(Math.random(picArray.length))])
}
function openWindow(imageName)
{
document.getElementById("testSize").src = subDirectory+imageName
windowOps = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,"
windowOps+= "width="+parseInt(document.getElementById("testSize").width)+","
windowOps+= "height="+parseInt(document.getElementById("testSize").height)+","
windowOps+= "left=250,top=50";
ImageWindow = window.open("","ImageWindow",windowOps);
windowHTML = "<img src=\""+(subDirectory+imageName)+"\">"
self.ImageWindow.document.clear();
self.ImageWindow.document.innerHTML=""
self.ImageWindow.document.write(windowHTML);
self.ImageWindow.focus();
self.ImageWindow.document.close();
}
</script>
p.s. NOT really a different type of random at all
:)