Mouseover events...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Uwe Allgäuer

    #1

    Mouseover events...

    Hi NG!

    I want to make my site more dynamic... but i dont find out how this works...

    On my site there is at the left side the navigation bar and at the rigt side
    i want to put a photo. The photo should change when someone puts the cursor
    over the links in the left side.

    Does anybody kno how this works?

    thx
    Uwe


  • Tony

    #2
    Re: Mouseover events...

    Make sure the <img> tag for the photo has an id="" attribute. In the
    onmouseover="" attribute of the link you can do something like:

    document.getEle mentById('photo Id').src='newph oto.jpg'

    This may not exactly work, but at least it points you in the right
    direction.

    Comment

    • Uwe Allgäuer

      #3
      Re: Mouseover events...


      "Tony" <tonylin919@gma il.com> schrieb im Newsbeitrag
      news:1101635871 .926559.295780@ f14g2000cwb.goo glegroups.com.. .[color=blue]
      > Make sure the <img> tag for the photo has an id="" attribute. In the
      > onmouseover="" attribute of the link you can do something like:
      >
      > document.getEle mentById('photo Id').src='newph oto.jpg'
      >
      > This may not exactly work, but at least it points you in the right
      > direction.
      >[/color]

      Boahh, that sounds very good! But i dont know it exactly, because I did not
      have much expiriences with javascript how it works...

      Is it possible to give with javescript a variable to html? So i could do a
      variable with an image and in the html tag i could say something like this:
      <img src="var1"...
      is this possible?

      thx Uwe


      Comment

      • Michael Winter

        #4
        Re: Mouseover events...

        On Sun, 28 Nov 2004 11:05:36 +0100, Uwe Allgäuer
        <uwe.allgaeuer@ students.fh-vorarlberg.ac.a t> wrote:
        [color=blue]
        > "Tony" <tonylin919@gma il.com> schrieb im Newsbeitrag
        > news:1101635871 .926559.295780@ f14g2000cwb.goo glegroups.com.. .[/color]

        [snip]
        [color=blue][color=green]
        >> document.getEle mentById('photo Id').src='newph oto.jpg'[/color][/color]

        The images collection is preferred:

        document.images['photoId'].src = '...';
        [color=blue]
        > Is it possible to give with javescript a variable to html?[/color]

        A way was proposed once, but it was never adopted, so no.

        [snip]

        What you're look for is something like

        function setPhoto(url) {
        document.images['photoId'].src = url;
        }

        where 'photoId' is the id attribute value of your main IMG element.

        On the links, you'd have

        <a ... onmouseover="se tPhoto('relativ e or absolute URL');">

        which would change the source of the IMG element to the value of the
        string.

        Note that this is a very simple approach to the problem.

        Hope that helps,
        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • Joakim Braun

          #5
          Re: Mouseover events...

          ----- Original Message -----
          From: "Uwe Allgäuer" <uwe.allgaeuer@ students.fh-vorarlberg.ac.a t>
          <snip>[color=blue]
          > Is it possible to give with javescript a variable to html? So i could do a
          > variable with an image and in the html tag i could say something like[/color]
          this:[color=blue]
          > <img src="var1"...
          > is this possible?[/color]

          No.

          In any case you'd still need to update the image path contained in var1
          onmouseover, so you wouldn't save any typing (beyond, perhaps, one line).

          Joakim Braun


          Comment

          • Uwe Allgäuer

            #6
            Re: Mouseover events...


            "Joakim Braun" <joakim.braun@j fbraun.removeth is.com> schrieb im Newsbeitrag
            news:zuiqd.1834 7$1p.15809@nntp server.swip.net ...[color=blue]
            > ----- Original Message -----
            > From: "Uwe Allgäuer" <uwe.allgaeuer@ students.fh-vorarlberg.ac.a t>
            > <snip>[color=green]
            > > Is it possible to give with javescript a variable to html? So i could do[/color][/color]
            a[color=blue][color=green]
            > > variable with an image and in the html tag i could say something like[/color]
            > this:[color=green]
            > > <img src="var1"...
            > > is this possible?[/color]
            >
            > No.
            >
            > In any case you'd still need to update the image path contained in var1
            > onmouseover, so you wouldn't save any typing (beyond, perhaps, one line).
            >
            > Joakim Braun
            >
            >[/color]

            Well thanks a lot to all!

            I try hard to do this, if there are other questions i will ask again... :-)

            Thx
            Uwe


            Comment

            Working...