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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Enlarging thumbnails stored in array

    So when the page loads the thumbnails cycle through using setInterval. When the user clicks on one of the thumbnails, it is supposed to open a new window and show the enlarged version of that thumbnail stored in bigpics. However it only comes up with a broken image link. Any ideas why this is not working? Here is the code:

    <html>
    <head>
    <title>Untitled</title>
    </head>
    <script language="JavaScript" type="text/javascript">
    <!--
    var pics = new Array()
    pics[0]="pict1.gif"
    pics[1]="pict2.gif"
    pics[2]="pict3.gif"
    pics[3]="pict4.gif"
    pics[4]="pict5.gif"
    pics[5]="pict6.gif"
    var bigpics = new Array()
    bigpics[0]="pict12.gif"
    bigpics[1]="pict22.gif"
    bigpics[2]="pict32.gif"
    bigpics[3]="pict42.gif"
    bigpics[4]="pict52.gif"
    bigpics[5]="pict62.gif"
    i=0
    setInterval("slide()",500)
    function slide(){
    if (i<pics.length)
    i++
    if (i==pics.length)
    i=0
    document.images[0].src=pics[i]
    }

    function enlarge(x){
    w=window.open()
    x=bigpics[i]
    w.document.write("<img src='x'>")
    }
    //-->
    </script>
    <body>
    <img src="pict1.gif" alt="" onclick="enlarge(this)">
    </body>
    </html>

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    Code:
    onclick="enlarge(this.src)">
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thats what i might have thought also, but when i try that it still comes up with a broken image link.

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    This
    Code:
    x=bigpics[i]
    w.document.write("<img src='x'>")
    will result in an image tag that is EXACTLY <img src='x'> but you want to concatenate the img tag string with the content of x
    Code:
    x=bigpics[i]
    w.document.write('<img src="' + x + '">')

  • Users who have thanked devnull69 for this post:

    Zwake (09-14-2011)

  • #5
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts
    ahh yes that worked thank you.


  •  

    Posting Permissions

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