PDA

View Full Version : Onmouseover / Onmouseout from javascript


allyson
06-28-2002, 06:06 AM
Hi

Is it possible call a javascript function from href=........to do the same thing as an onmouseover command.

bye
Allyson

glenngv
06-28-2002, 06:40 AM
<a href="javascript:function1()" onmouseover="function2()" onmouseout="function3()">Link</a>

Originally posted by allyson
Hi

Is it possible call a javascript function from href=........to do the same thing as an onmouseover command.

bye
Allyson

allyson
06-28-2002, 06:57 AM
Hi

Thanks for the response, but it's not quite want I was after. I'm know that onmouseover/out commands usually go after href=....... but they do not seem to work with an image map. I'm using Frontpage 98 and won't allow me to use onmouseover commands with the imagemapping format. What I wanted to do was to call onmouseover from a script, something like:

function1 {

onmouseover="function2"
openurl('http://....."
}

href="javascript:function1"


bye
Allyson

glenngv
06-28-2002, 07:11 AM
you can do this but the mouseover/mouseout will only function once the the link is clicked.

function openLink(objLink){
objLink.onmouseover=mOver;
objLink.onmouseout=mOut;
window.open('page.htm');
}

function mOver(){
//code here
}

function mOut(){
//code here
}

<a href="javascript:openLink(this)">Link</a>

ronaldb66
06-28-2002, 12:18 PM
I've done some research, but the AREA object should fire Mouseover and Mouseout events just as an A object would, unless this is not part of the DOM yet.
What do you want to use the onMouseOver and onMouseOut event handlers for, aka what kind of funtion do you want to call? Maybe there's a workaround or such...

ronaldb66
06-28-2002, 01:11 PM
I tried something like:

<map ...>
<area href="..." onMouseOver="alert('this is a circle!')" ...>
...
</map>

(dots: ... represent uninteresting bits left out here)
and that works just fine in IE 5.0! Simply add a mouseover event handler somewhere within the area tag and you can call whatever function you please.