Image: MouseOver - MouseOut - OnClick problem

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Image: MouseOver - MouseOut - OnClick problem

    Imagine this:

    I have a gif-image with text, coloured green.
    When MouseOver occurs the gif will swap to another gif with red colourded
    text. On MouseOut the gif turns back to the green text.

    -----------------This is my code:

    <a href="nextpage.html" onMouseOver="document.green.src='red.gif'"
    onMouseOut="document.green.src='green.gif'">
    <img src="green.gif"></a>

    -----------------

    After clicking this link, I want the image to stay red. How can I manage
    this??
    Problem is that on MouseOut the image turns green again... :-(

    I tried CSS using an transparent gif with backgroundimages, but it still
    doesn't work.

    Can someone help me out?

    John



    John Guest

  2. Similar Questions and Discussions

    1. Mouseover behaviour vs. onClick
      i have a easy qestion. how can i change mouseover behavior to on click?
    2. image on mouseover close on mouseout
      Howdy, I have an imagemap with 4 sections. I want to mouseover and show that image and close it on mouseout. The openbrowser window behavior is...
    3. Mouseover changes another image
      Hello all. I am wondering how to accomplish something. Im almost positive I have done this before when I learned HTML but I couldnt find anything...
    4. Mouseover, mouseout, click etc on datagrid.
      Hi there, Does anyone know of a way that I can specify javascript functions that are to be run when a cell is clicked, mouse over etc in a datagrid...
    5. Changing an image on mouseover?
      Can anyone tell me if it is possible to change an image on mouseover? What I am trying to do is make one of my buttons change to a different image...
  3. #2

    Default Re: Image: MouseOver - MouseOut - OnClick problem

    Maybe you could look into adapting this ?

    [url]http://www.projectseven.com/tutorials/css_menus/list_01/[/url]


    John wrote:
    > Imagine this:
    >
    > I have a gif-image with text, coloured green.
    > When MouseOver occurs the gif will swap to another gif with red colourded
    > text. On MouseOut the gif turns back to the green text.
    >
    > -----------------This is my code:
    >
    > <a href="nextpage.html" onMouseOver="document.green.src='red.gif'"
    > onMouseOut="document.green.src='green.gif'">
    > <img src="green.gif"></a>
    >
    > -----------------
    >
    > After clicking this link, I want the image to stay red. How can I manage
    > this??
    > Problem is that on MouseOut the image turns green again... :-(
    >
    > I tried CSS using an transparent gif with backgroundimages, but it still
    > doesn't work.
    >
    > Can someone help me out?
    >
    > John
    >
    >
    >
    Citizen Trout Guest

  4. #3

    Default Re: Image: MouseOver - MouseOut - OnClick problem

    In <mztUb.10427$%i5.762@news-binary.blueyonder.co.uk> Citizen Trout <nospam@this.com> writes:
    >John wrote:
    >> Imagine this:
    >>
    >> I have a gif-image with text, coloured green.
    >> When MouseOver occurs the gif will swap to another gif with red colourded
    >> text. On MouseOut the gif turns back to the green text.
    >> After clicking this link, I want the image to stay red. How can I manage
    >> this??
    >> Problem is that on MouseOut the image turns green again... :-(
    >>
    >> I tried CSS using an transparent gif with backgroundimages, but it still
    >> doesn't work.
    It's not a coding problem, it's a logic problem. You're going to need to
    save the state of the button. So you'll need an image called something
    like "button_1_postclick" where you set the .src initially to green.gif,
    and then have the onMouseOut set the gif to button_1_postclick rather than
    to green.gif. Then have your onClick function for button_1 change the .src
    of button_1_postclick to red.gif

    Or I suppose you could do it with a global variable -- "button_1_clicked"
    flag. Then have your onMouseOut check the variable - if not
    button_1_clicked then swap gif to green, else leave it red, and have
    onMouseOut set button_1_clicked = true.

    Hope that helps.

    --sg


    >>
    >> Can someone help me out?
    >>
    >> John
    >>
    >>
    >>
    --
    ---------------------------------------
    Buy my boat!
    [url]http://www.oscodagroup.com/boat[/url]

    Steve Goldfarb Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139