SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot abwebs's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, PA
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hover but no link

    Hello,
    I have what seems to be a simple idea, but I can't seem to figure out how to implement it. I'd like to have one .jpg swap for another .jpg when a user hovers over the image with their mouse, however I DO NOT want the .jpg to have an active link to another html page if clicked.

    Could I do this with a Javascript? The Jscripts I am familiar with require a link.

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    yeah, but why not just have <a href="javascript:blah()">... though it's a link it doesn't GO anywhere. However, you CAN put the <img src="whocares.jpg" onMouseover="switch()"> but it will not work in certain browsers.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    SitePoint Zealot abwebs's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, PA
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by studiococo
    yeah, but why not just have <a href="javascript:blah()">... though it's a link it doesn't GO anywhere. However, you CAN put the <img src="whocares.jpg" onMouseover="switch()"> but it will not work in certain browsers.
    I am by no means a JS expert so please bear with me.
    What do you mean it doesn't GO anywhere? Thanks to maximumedge I tried

    <a href="java scriptver()" onmouseover="over();return true" onmouseout="out();return true"> <IMG SRC="example.jpg"> </a>
    and the image is still 'active' to click on for the user. The user would click on it and get a file not found.

    Is this what you are referring to in your first example?

    thanks.

  4. #4
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah, do this instead:

    <div onmouseover="over()" onmouseout="out()"><img src="whatever.jpg"></div>
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  5. #5
    SitePoint Zealot
    Join Date
    Apr 2001
    Location
    Toronto, Ontario, Canada, Earth
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by abwebs
    am by no means a JS expert so please bear with me.
    What do you mean it doesn't GO anywhere? Thanks to maximumedge I tried

    <a href="java scriptver()" onmouseover="over();return true" onmouseout="out();return true"> <IMG SRC="example.jpg"> </a>
    and the image is still 'active' to click on for the user. The user would click on it and get a file not found.

    Is this what you are referring to in your first example?

    thanks.
    change 'java script' to one word and it should work.

    Jason

  6. #6
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sitepoint separates the java and the script so that scripts can't be executed ever.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  7. #7
    SitePoint Zealot abwebs's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, PA
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by maximumedge
    change 'java script' to one word and it should work.

    Jason
    IT WORKS!! ITWORKS!! ITWORKS!!

    Jason, It still gives an hourglass like it is going somewhere in Netscape (does nothing in IE), do I have to be concerned about it being invalid code, or just tolerate the usual Netscape nuances?

    <div onmouseover="over()" onmouseout="out()"><img src="whatever.jpg"></div>
    studiococco - this didn't work for me , but thanks for your assistance!
    Last edited by abwebs; Jun 28, 2001 at 07:53.


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
  •