Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    onMouseOver problem

    I want to do something ridiculously simple: I want a small (315x275 px) popup window to open up containing some text in myfile.html when the mouse goes over a test image.

    I thought the code should be:

    <a href="myfile.html" onMouseOver="return pop315x275('myfile.html')"><img src="test_image.jpg" alt=""></a>

    The reason I thought this would work is that if onclick is used instead of onMouseOver, it works perfectly (with a click of course). But using onMouseOver, nothing happens when the mouse goes over the image.

    Apparently I have a fundamental misunderstanding about event handlers.

    Sorry to be so thick; will appreciate help.

    jockm

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try using the mouseover event inisde the image element, not inside the link element.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Okay, now it reads


    <a href="myfile.html"><img onMouseOver="return pop315x275('myfile.html')" src="test_image.jpg" alt=""></a>

    and it still doesnt work.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    remove the return. And probably your function pop315x275() has as last line something like

    return false;

    Remove that as well.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New Coder
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Now I have removed the return from the main code, and also the false from the function, so the function now reads

    function pop310x275(url)
    {
    newwindow=window.open(url,'name','height=315,width=275,top=200,left=300');
    if (window.focus) {newwindow.focus()};
    }

    (I created pop310x275 because I use pop315x275 in other places where the false is probably needed.)

    Still doesnt work.

  • #6
    New Coder
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts
    According to Joe Burns (HTML GOODIES) event handlers onClick and onMouseOver work identically.

    No wonder us ordinary folk find javascript so mystifying.

    They certainly do NOT work identically. Every illustration of the use of onMouseOver that I can find refers either to image swaping or to sending some text into the status bar. Opening a small popup window with onMouseOver seems beyond its ability.

    So I have ended up making the text I wanted to appear in a popup html document an image and swapping it onMouseOver. That works but it isnt really what I want as the text has to be squeezed into the same size image as the mouseOut image. And also the mouseOut image disappears. But its better than nothing. Yuk!

  • #7
    New Coder
    Join Date
    Aug 2006
    Location
    Idaho
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Try This

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
     <title>Untitled</title>
    <script>
    function pop310x275(url){
    newwindow=window.open(url,'name','height=315,width=275,top=200,left=300');
    if (window.focus) {
    newwindow.focus()
    };
    }
    </script>
    </head>
    <body>
    <img onMouseOver="pop310x275('myfile.html')" src="test_image.jpg" alt="">
    </body>
    </html>
    .
    + Christ is the Rock - Rock On!


  •  

    Posting Permissions

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