Show image on mouse over a link

Discussion in 'PHP' started by emi87, Sep 18, 2008.

  1. #1
    Hello,

    I need a script to show a small image near the mouse when I put the mouse over a link.
    I don't want to disappear the link and show the image. I want to be both there.

    for example. when you put the mouse over this link www.dsfkjsdlkg.com I want to show a thumbnail image with me near the cursor.

    Thank you.
     
    emi87, Sep 18, 2008 IP
  2. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is done in javascript, not PHP..
    Don't know how though :/
    Maybe some JS libraries have this function - look up jquery, scriptaculous, prototype or mootools or something

    Hope it helps ;)
     
    lui2603, Sep 18, 2008 IP
  3. AnonymousUser

    AnonymousUser Peon

    Messages:
    593
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Its possible with just CSS.

    google the :hover tag
     
    AnonymousUser, Sep 18, 2008 IP
  4. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I thought they meant thumbnails which float above the link & move with the mouse position
    like I've seen used on some websites... Don't think it can be done with :hover though
     
    lui2603, Sep 18, 2008 IP
  5. hip_hop_x

    hip_hop_x Active Member

    Messages:
    522
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #5
    javascript is the best solution for this problem, post this there or ask a mod to move it
     
    hip_hop_x, Sep 18, 2008 IP
  6. fireworking

    fireworking Peon

    Messages:
    460
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    fireworking, Sep 18, 2008 IP
  7. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #7
    You only need to get the mouse position, and then write the IMG tag in a hidden div. Using javascript place the hidden div next to mouse position.

    document.getElementById("mydiv").style.position="absolute";
    document.getElementById("mydiv").style.top="200px";


    See this example:
    http://www.businessbazee.com/
    Click Search link in blue bar.
    That is "onclick", you need "onmouseover"

    Do a google search to get a code to "find mouse position with javascript". So many there. :)
    regards :)
     
    JEET, Sep 18, 2008 IP
  8. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #8
    I would prefer the solution proposed by JEET than the CSS one. If you really need to put the image on the onmouseover event at the cursor location and remove it when onmouseout then a DIV with the image inside (with display style parameter) is your best hope!
    Then you need to check the realtime position of the cursor and that might be tricky with different code for each browser.
     
    webrickco, Sep 19, 2008 IP