Swap image on clicking a link

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dougawells@gmail.com

    Swap image on clicking a link

    There are probably lots of good examples that I haven't found yet. I
    want a link on a page to swap out two or three images that are on the
    same page. Can someone please point me towards an example? I'm used to
    doing this in Flash, not in HTML and Javascript.
    Thanks
  • Ed Jay

    #2
    Re: Swap image on clicking a link

    dougawells@gmai l.com scribed:
    >There are probably lots of good examples that I haven't found yet. I
    >want a link on a page to swap out two or three images that are on the
    >same page. Can someone please point me towards an example? I'm used to
    >doing this in Flash, not in HTML and Javascript.
    >Thanks
    Google 'swap images'. There's a bunch. Then use onClick to call whichever
    function you choose to use.

    Ed Jay (remove 'M' to reply by email)

    --
    Win the War Against Breast Cancer.
    Knowing the facts could save your life.

    Comment

    • Roderik

      #3
      Re: Swap image on clicking a link

      dougawells@gmai l.com schreef:
      There are probably lots of good examples that I haven't found yet. I
      want a link on a page to swap out two or three images that are on the
      same page. Can someone please point me towards an example? I'm used to
      doing this in Flash, not in HTML and Javascript.
      Thanks
      First hit from Google (http://www.devx.com/tips/Tip/13653):

      <HTML>
      <HEAD>
      <SCRIPT LANGUAGE=JavaSc ript>
      intImage = 2;
      function swapImage() {
      switch (intImage) {
      case 1:
      IMG1.src = "http://www.microsoft.c om/library/toolbar/images/mslogo.gif"
      intImage = 2
      return(false);
      case 2:
      IMG1.src =
      "http://msdn.microsoft. com/msdn-online/start/images/msdn-logo.gif"
      intImage = 1
      return(false);
      }
      }
      </SCRIPT>
      </HEAD>
      <BODY>
      <IMG id="IMG1" name="IMG1"
      src="http://www.microsoft.c om/library/toolbar/images/mslogo.gif"
      onclick="swapIm age();">
      </BODY>
      </HTML>

      The code is a bit old fashioned (there should be a type for the script
      and it should be hidden somewhat from the html IMO) but it is prob. easy
      to adjust it. Of course you could also choose to use the hover event or
      any other.

      --
      Web development en webhosting

      webdesign, internet applicaties, internetgestuur de elektronica

      Comment

      Working...