6 Replies Latest reply on Sep 13, 2008 6:19 AM by Newsgroup_User

    How do I hotlink Images in a Javascript?

    Level 1
      Here is the website in question:

      http://www.addaxtactical.com

      Basically the client now wants me to make the random image script images a link back to the home page. Simple, right? Well I can't quite figure it out since they are javascript. How do I do this?

      Thanks
      Joe
        • 1. Re: How do I hotlink Images in a Javascript?
          Level 7
          var whichImage = Math.round(Math.random()*(p-1));
          function showImage(){
          document.write('<a href="index.html"><img
          src="'+theImages[whichImage]+'"><'+'/a>');
          }


          --
          Murray --- ICQ 71997575
          Adobe Community Expert
          (If you *MUST* email me, don't LAUGH when you do so!)
          ==================
          http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
          http://www.dwfaq.com - DW FAQs, Tutorials & Resources
          ==================


          "JSloanSDRE" <webforumsuser@macromedia.com> wrote in message
          news:gaevdt$sg$1@forums.macromedia.com...
          > Here is the website in question:
          >
          > http://www.addaxtactical.com
          >
          > Basically the client now wants me to make the random image script images a
          > link back to the home page. Simple, right? Well I can't quite figure it
          > out
          > since they are javascript. How do I do this?
          >
          > Thanks
          > Joe
          >
          > <script language="JavaScript">
          > var theImages = new Array()
          >
          > theImages[0] = 'adxwide.png'
          > theImages[1] = 'adxwide1.png'
          > theImages[2] = 'adxwide2.png'
          > theImages[3] = 'adxwide3.png'
          > theImages[4] = 'adxwide4.png'
          > theImages[5] = 'adxwide5.png'
          > theImages[6] = 'adxwide6.png'
          >
          > var j = 0
          > var p = theImages.length;
          >
          > var preBuffer = new Array()
          > for (i = 0; i < p; i++){
          > preBuffer = new Image()
          > preBuffer
          .src = theImages
          > }
          >
          > var whichImage = Math.round(Math.random()*(p-1));
          > function showImage(){
          > document.write('<img src="'+theImages[whichImage]+'">');
          > }
          > </script>
          >

          • 2. How do I hotlink Images in a Javascript?
            Level 1
            Hmm, I added it, and now no images show up?

            check out www.adxtactical.com to see what Im talking about (EDIT: I just replaced it with the old code, so now the pictures are appearing normally, but still not hotlinked)

            Here is the code now:

            <script language="JavaScript">
            var theImages = new Array()

            theImages[0] = 'adxwide.png'
            theImages[1] = 'adxwide1.png'
            theImages[2] = 'adxwide2.png'
            theImages[3] = 'adxwide3.png'
            theImages[4] = 'adxwide4.png'
            theImages[5] = 'adxwide5.png'
            theImages[6] = 'adxwide6.png'

            var j = 0
            var p = theImages.length;

            var preBuffer = new Array()
            for (i = 0; i < p; i++){
            preBuffer = new Image()
            preBuffer
            .src = theImages
            }

            var whichImage = Math.round(Math.random()*(p-1));
            function showImage(){
            document.write('<a href=" http://www.adxtactical.com"><img>
            src="'+theImages[whichImage]+'"><'+'/a>');
            }
            </script>


            Here is the second part of the code:

            <script language="JavaScript">
            showImage();
            //-->
            </script>
            • 4. Re: How do I hotlink Images in a Javascript?
              Level 7
              <a href=" http://www.adxtactical.com"><img
              src="'+theImages[whichImage]+'"><'+'/a>');



              --
              Murray --- ICQ 71997575
              Adobe Community Expert
              (If you *MUST* email me, don't LAUGH when you do so!)
              ==================
              http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
              http://www.dwfaq.com - DW FAQs, Tutorials & Resources
              ==================


              "JSloanSDRE" <webforumsuser@macromedia.com> wrote in message
              news:gaf5jm$6vm$1@forums.macromedia.com...
              > Hmm, I added it, and now no images show up?
              >
              > check out www.adxtactical.com to see what Im talking about
              >
              > Here is the code now:
              >
              > <script language="JavaScript">
              > var theImages = new Array()
              >
              > theImages[0] = 'adxwide.png'
              > theImages[1] = 'adxwide1.png'
              > theImages[2] = 'adxwide2.png'
              > theImages[3] = 'adxwide3.png'
              > theImages[4] = 'adxwide4.png'
              > theImages[5] = 'adxwide5.png'
              > theImages[6] = 'adxwide6.png'
              >
              > var j = 0
              > var p = theImages.length;
              >
              > var preBuffer = new Array()
              > for (i = 0; i < p; i++){
              > preBuffer = new Image()
              > preBuffer
              .src = theImages
              > }
              >
              > var whichImage = Math.round(Math.random()*(p-1));
              > function showImage(){
              > document.write('<a href=" http://www.adxtactical.com"><img>
              > src="'+theImages[whichImage]+'"><'+'/a>');
              > }
              > </script>
              >

              • 5. Re: How do I hotlink Images in a Javascript?
                Level 7
                Murray showed the correction. Remove the extra > between img and src.

                Your code:
                <a href=" http://www.adxtactical.com"><img>
                src="'+theImages[whichImage]+'"><'+'/a>');

                Murray's code:
                <a href=" http://www.adxtactical.com"><img
                src="'+theImages[whichImage]+'"><'+'/a>');


                Take care,
                Tim



                "JSloanSDRE" <webforumsuser@macromedia.com> wrote in message
                news:gafbvs$d61$1@forums.macromedia.com...
                > lil help here


                • 6. Re: How do I hotlink Images in a Javascript?
                  Level 7
                  Replace it with a space just to be sure.

                  --
                  Murray --- ICQ 71997575
                  Adobe Community Expert
                  (If you *MUST* email me, don't LAUGH when you do so!)
                  ==================
                  http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
                  http://www.dwfaq.com - DW FAQs, Tutorials & Resources
                  ==================


                  "TC2112" <nospam@nospam.com> wrote in message
                  news:gageck$iie$1@forums.macromedia.com...
                  > Murray showed the correction. Remove the extra > between img and src.
                  >
                  > Your code:
                  > <a href=" http://www.adxtactical.com"><img>
                  > src="'+theImages[whichImage]+'"><'+'/a>');
                  >
                  > Murray's code:
                  > <a href=" http://www.adxtactical.com"><img
                  > src="'+theImages[whichImage]+'"><'+'/a>');
                  >
                  >
                  > Take care,
                  > Tim
                  >
                  >
                  >
                  > "JSloanSDRE" <webforumsuser@macromedia.com> wrote in message
                  > news:gafbvs$d61$1@forums.macromedia.com...
                  >> lil help here
                  >
                  >