www.webdeveloper.com
Results 1 to 2 of 2

Thread: newbie javascript problem

  1. #1
    Join Date
    Jul 2010
    Posts
    7

    newbie javascript problem

    Hi,

    Im a complete newbie to javascript and I've basically copied and pasted the javascript I found here to use on my site. Its an onMouseOver slidesow:

    http://www.javascriptkit.com/script/...ifferent.shtml

    to use on my site.

    Basically, my problem is how do I add a second, separate image in a different location on the web page, associated with this script?


    If I post <a href="javascript:warp()"><img src="myimage" name="targetimage" border=0></a> in two different locations, which is the script for the image, the script stops working, but having it once makes it work. So how do I add two different image locations?

    Can someone please help me here? I just want to add more images in a different location. ie have image location 1, and image location 2.

    Thanks in advance

    Script Below:


    <script>

    function changeimage(towhat,url){
    if (document.images){
    document.images.targetimage.src=towhat.src
    gotolink=url
    }
    }
    function warp(){
    window.location=gotolink1
    }
    </script>
    <script language="JavaScript1.1">
    var myimages=new Array()
    var gotolink="#"

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


    preloadimages(my images here)

    </script>

    For the Links:

    <a href="creativewriting.html" onMouseover="changeimage(myimages[1],this.href)">Creative Writing</a><br>

    For the Image:

    <a href="javascript:warp()"><img src="myimage" name="targetimage" border=0></a>

  2. #2
    Join Date
    Jan 2005
    Location
    Frankfort, KY, USA
    Posts
    6,167
    Add this to the javascript:
    Code:
    var myimages2=new Array()
    var gotolink="#"
    
    function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
    myimages2[i]=new Image()
    myimages2[i].src=preloadimages.arguments[i]
    }
    }
    
    
    preloadimages(my images here)
    Code for the links:
    Code:
    <a href="creativewriting.html" onMouseover="changeimage(myimages2[1],this.href)">Creative Writing</a><br>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles