...

View Full Version : onMouseOver problem



jockm
08-29-2006, 03: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.

jockm

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

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

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

return false;

Remove that as well.

jockm
08-29-2006, 05: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)
{
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.

jockm
08-30-2006, 09: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!

Scriptbanger
08-30-2006, 07:15 PM
<!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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum