View Full Version : onMouseOver problem

08-29-2006, 04:57 PM
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.


08-29-2006, 05:07 PM
try using the mouseover event inisde the image element, not inside the link element.

08-29-2006, 05:43 PM
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.

08-29-2006, 06:02 PM
remove the return. And probably your function pop315x275() has as last line something like

return false;

Remove that as well.

08-29-2006, 06:21 PM
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)
if (window.focus) {newwindow.focus()};

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

Still doesnt work.

08-30-2006, 10:43 AM
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!

08-30-2006, 08:15 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
function pop310x275(url){
if (window.focus) {
<img onMouseOver="pop310x275('myfile.html')" src="test_image.jpg" alt="">