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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A different random image link script question

    I recently had a problem with a random image link script that I got taken care of, and am now experiencing something of a similar issue with the same script when I try to get it to link to images instead of webpages.. here is the script:

    Code:
    <script language="JavaScript"> 
    var rand1=Math.floor(Math.random()*5)+1
    images = new Array(5) 
    images[1] = "art/thumbs/s7thumb.gif" 
    images[2] = "art/thumbs/s8thumb.gif" 
    images[3] = "art/thumbs/aathumb.jpg" 
    images[4] = "art/barbariansketchthumb.gif" 
    images[5] = "art/thumbs/s1thumb.gif" 
    
    var image = images[rand1] 
    
    links = new Array(5) 
    links[1] = "http://www.cr6productions.com/art/sketch7.jpg" 
    links[2] = "http://www.cr6productions.com/art/sketch8.jpg" 
    links[3] = "http://www.cr6productions.com/art/archangel.jpg" 
    links[4] = "http://www.cr6productions.com/art/barbariansketch.jpg" 
    links[5] = "http://www.cr6productions.com/art/sketch1.jpg" 
    
    var link = links[rand1] 
    </script> <script> 
    function hitmeup() { 
    newWindow = window.open('http://'+link+'', 'newWin', 'toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes, status=yes, width=700, height=525') 
    } 
    </script> <script language="JavaScript"> 
    document.write('<a href="javascript:hitmeup()"><IMG SRC="' + image + '" border="2"></a>') 
    </script>
    It displays the thumb nails fine, but when the thumb is clicked it brings up a page cannot be displayed window, instead of the image i'm trying to link it to, can anyone advise how to correct this issue?

    Any and all assistance is greatly appreciated,
    thanks in advance

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    rand1 is set to a random number as the page is loaded but is not updated after that

    PHP Code:
    <script>
    function 
    hitmeup() {
     
    link links[Math.floor(Math.random()*5)+1];
     
    newWindow window.open('http://'+link+'''newWin''toolbar=no, location=no, directories=no, scrollbars=yes, resizable=yes, status=yes, width=700, height=525')
    }
    </script> 


  •  

    Posting Permissions

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