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

    Javascript Image link Problem

    Hey I am having problems with this code, Its supose to open a link every time you click on a different image every different image will take you to separate different links but whats happening is that its not leting me click the images and it wont take me to the links.

    Can some one pls take a look at it and let me know whats rong with it? Thanx!


    Code:
    <html>
    <head>
    <script language="JavaScript1.1">
    
    var slideimages=new Array()
    var slidelinks=new Array()
    
    function slideshowimages(){
    for (i=0;i<slideshowimages.arguments.length;i++){
    slideimages[i]=new Image()
    slideimages[i].src=slideshowimages.arguments[i]
    }
    }
    
    function slideshowlinks(){
    for (i=0;i<slideshowlinks.arguments.length;i++)
    slidelinks[i]=slideshowlinks.arguments[i]
    }
    
    function gotoshow(){
    if (!window.winslide||winslide.closed)
    winslide=window.open(slidelinks[whichlink])
    else
    winslide.location=slidelinks[whichlink]
    winslide.focus()
    }
    
    </script>
    
    <title>Untitled</title>
    </head>
    
    <body onload="slideit();">
    <script>
    
    slideshowimages("One.gif", "Two.gif", "Three.gif")
    slideshowlinks("http://mysite.com", "http://mysite.com", "http://mysite.com")
    
    
    var slideshowspeed=2000
    var whichlink=0
    var whichimage=0
    
    function slideit(){
    if (!document.images)
    return
    document.images.slide.src=slideimages[whichimage].src
    whichlink=whichimage
    
    if (whichimage<slideimages.length-1)
    whichimage++
    else
    whichimage=0
    setTimeout("slideit()",slideshowspeed)
    }
    
    
    </script>
    
    <img name="slide">
    
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try this

    PHP Code:
    <html>
    <
    head>
    <
    script language="JavaScript1.1">

    var 
    slideimages=new Array()
    var 
    slidelinks=new Array()

    function 
    slideshowimages(){
    for (
    i=0;i<slideshowimages.arguments.length;i++){
    slideimages[i]=new Image()
    slideimages[i].src=slideshowimages.arguments[i]
    }
    }

    function 
    slideshowlinks(){
    for (
    i=0;i<slideshowlinks.arguments.length;i++)
    slidelinks[i]=slideshowlinks.arguments[i]
    }

    function 
    gotoshow(url){
    if (!
    window.winslide||winslide.closed)
    winslide=window.open(url)
    else
    winslide.location=url
    winslide
    .focus()
    }

    </script>

    <title>Untitled</title>
    </head>

    <body onload="slideit()">
    <script>

    slideshowimages("One.gif", "Two.gif", "Three.gif")
    slideshowlinks("http://mysite1.com", "http://mysite2.com", "http://mysite3.com")


    var slideshowspeed=2000
    var whichlink=0
    var whichimage=0

    function slideit(){
    if (!document.images)
    return

    document.images.slide.src=slideimages[whichimage].src
    document.getElementById("lnk").href=slidelinks[whichimage]

    if (whichimage<slideimages.length-1)
    whichimage++
    else
    whichimage=0
    setTimeout("slideit()",slideshowspeed)
    }


    </script>

    <a id="lnk" href="#null" onclick="gotoshow(this.href) ; return false"><img name="slide"></a>

    </body>
    </html> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,

    I came across this script and thought I could modify it to my own needs, but it's not working for me. (I do not see any images) If there are any obvious errors, I would be grateful if someone could point them out. I'm starting to think I didn't pick the best script for my needs.


    Code:
    <script*language="JavaScript1.1"> 
    
    var*slideimages=new*Array() 
    var*slidelinks=new*Array() 
    
    function*slideshowimages(){ 
    for*(i=0;i<slideshowimages.arguments.length;i++){ 
    slideimages[i]=new*Image() 
    slideimages[i].src=slideshowimages.arguments[i] 
    } 
    } 
    
    function*slideshowlinks(){ 
    for*(i=0;i<slideshowlinks.arguments.length;i++) 
    slidelinks[i]=slideshowlinks.arguments[i] 
    } 
    
    function*gotoshow(url){ 
    if*(!window.winslide||winslide.closed) 
    winslide=window.open(url) 
    else 
    winslide.location=url 
    winslide.focus() 
    } 
    
    </script>
    Code:
    <body onload="slideit()" id="intro">
    
    <script>
    
    slideshowimages("/img/slideshow/01.jpg", "/img/slideshow/02.jpg", "/img/slideshow/03.jpg")
    slideshowlinks("/furnishings/lounge_chairs/product_14/index.php", "/furnishings/lounge_chairs/product_6/index.php", "/furnishings/dining_side_chairs/product_18/index.php")
    
    
    var slideshowspeed=2000
    var whichlink=0
    var whichimage=0 
    
    function slideit(){
    if (!document.images)
    return
    
    document.images.slide.src=slideimages[whichimage].src
    document.getElementById("lnk").href=slidelinks[whichimage]
    
    if (whichimage<slideimages.length-1)
    whichimage++
    else
    whichimage=0
    setTimeout("slideit()",slideshowspeed)
    } 
    </script>
    
    <div id="wrapper">
    	<h1><span>Quasi Modo</span></h1>
    	<h2><span>Modern Furniture</span></h2>
    	<?php include ("inc/nav.php") ?>
    	<div id="slide">
    		 <a id="lnk" href="#null" onclick="gotoshow(this.href) ; return false"><img name="slide" /></a></div>
    	<div id="content">
    	<p>Since 1981, <em>Quasi Modo Modern Furniture</em> has specialized in retailing modernist furniture, lighting and accessories for the home and office by some of the world's most renowned designers and manufacturers.</p>
    	</div>
    <?php include ("inc/footerhome.php") ?></div>
    
    </body>
    Any help would be appreciated... I'm still learning how this all works!
    Thanks.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    In your script you have asterisks * where there should be a space?
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The asteriks are spaces in my file... something must have happened with the cutting and pasting.

    I'm still not having any luck with the script.

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    I replaced the asterisks in your script with spaces and the script ran ok
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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