Results 1 to 8 of 8

Thread: Is it possible to have 2 mouseover events linked to a single image?

  1. #1
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is it possible to have 2 mouseover events linked to a single image?

    I want to modify the Thumbnail viewer Script II slightly, and turn it into a site navigation system. For the most part I got it to work fine, but the only thing i'm having trouble with is, while using a button instead of a thumbnail image, getting an actual mouseover effect (highlight, press, change, whatever) to work on the button itself (mouseover created using image ready). Because the thumbnail viewer script also calls for an onmouseover event on the same image is it just not possible to have 2 effects linked to the same button? Or am I just not doing it right? I suppose this could fall under the "2 scripts on one page" disclaimer... but even just a simple yes or no it is or isnt possible would be great so I don't waste another full night trying to make it work

    Thanx in advance...
    Malice

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    In general, yes, you can have two (or more) onMouseover events within the same tag simply by separating each action with a simicolon. For example:
    Code:
    <a href="#" onMouseover="dothis(); dothat()">
    where dothis() and dothat() are two separate functions.

  3. #3
    Join Date
    Oct 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanx, that made sense...unfortunitely when I do that I get the IE scripting error popup, so it cant be that easy

    Appreciate the help tho... i'm gonna keep playing with it til I get it right or my brain turns to mush.

  4. #4
    Join Date
    Jan 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Great Help! Finally!

    Thanks so much for explaining how to create 2 or more effects in a mouseover script! Now I can create my pages much more professionally!

    I still only have one problem: I sometimes use geocities! to create pages. when i preview them with a shake applet , they work. but when i view my actual web page, (i which i shortened the addres with shorturl), the shaking does not work. i combined a shake and a sound effect and they both worked on the button text in the geocities preview, but i the real page on the net, only the sound effect works!!!! WHY!!!!? Can anyone help!?

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Malice
    unfortunitely when I do that I get the IE scripting error popup, so it cant be that easy
    It is. The error is probably located in one of the functions called by the event listener.

    Mike

  6. #6
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    mwinter...could you explain what you mean by "error is probably located in one of the functions called by the event listener"...i'm having the same exact issue as malice and couldn't get my script to work. i didn't get an error message though in IE, but my rollover image just simply doesn't work.

    here's an example of the way i've got it right now:

    <a href="page.html" onmouseover="changetext(content[0]); "document.myimage.src=img2blue.src" onmouseout="document.myimage.src=img2.src"><img src="images/thegraphic_n.gif" width="145" height="23" border="0" name="myimage"></a>

    i'm not too experienced with javascript yet...so my error may be totally obvious.

  7. #7
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    ok...i totally missed it.

    i just figured out my problem. i had an extra quotation mark before document.myimage.src.

    so nevermind i got it to work now.

  8. #8
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by capescafe
    document.myimage.src
    The correct way to access an image is using the images collection:

    Code:
    document.images['myimage'].src
    By the way, there is a more maintainable (and less bloated) way to perform rollovers than explicitly adding mouseover/mouseout event listeners to every image. I can't post a link yet as I want to rewrite the script but if you're interested, I'll post again later.

    Mike

Bookmarks

Posting Permissions

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