Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-29-2006, 03:57 PM   PM User | #1
jockm
New Coder

 
Join Date: Jul 2006
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
jockm is an unknown quantity at this point
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
jockm is offline   Reply With Quote
Old 08-29-2006, 04:07 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
try using the mouseover event inisde the image element, not inside the link element.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 08-29-2006, 04:43 PM   PM User | #3
jockm
New Coder

 
Join Date: Jul 2006
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
jockm is an unknown quantity at this point
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.
jockm is offline   Reply With Quote
Old 08-29-2006, 05:02 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
remove the return. And probably your function pop315x275() has as last line something like

return false;

Remove that as well.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 08-29-2006, 05:21 PM   PM User | #5
jockm
New Coder

 
Join Date: Jul 2006
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
jockm is an unknown quantity at this point
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 is offline   Reply With Quote
Old 08-30-2006, 09:43 AM   PM User | #6
jockm
New Coder

 
Join Date: Jul 2006
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
jockm is an unknown quantity at this point
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!
jockm is offline   Reply With Quote
Old 08-30-2006, 07:15 PM   PM User | #7
Scriptbanger
New Coder

 
Join Date: Aug 2006
Location: Idaho
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Scriptbanger is an unknown quantity at this point
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!
Scriptbanger is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:14 PM.


Advertisement
Log in to turn off these ads.