Link to home
Start Free TrialLog in
Avatar of xabi
xabi

asked on

javascript null function.

Hi there:
I would like to make a image with no HREF but with an onmouseover in it. So i code this:

..
..
function donothing() {
}
</script>
<body>
..
..
<a href="javascript:donothing()" onMouseOver="foo1('resultado');return true"><img src="foo.gif"></a>
..
..

Ok, it works fine, but when I push the image my cursor changes into the hourglass (*clock) like if I was pressing over a link image. Is there any way to avoid this annoying hourglass (*clock)? Is there any way to asociate a javascript function to an image without HREF?

Thanks in advance.

(*) My English is really bad, so I'm not sure if "hourglass" is the correct word for the wait clock of windows 95.
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

function donothing() { return false; }

but that of course will change it into a hand instead.

In MSIE 4 and Netscape 4 you should be able to use DHTML to swap divs and layers on mouseovers on any html element

Michek
Avatar of xabi
xabi

ASKER

I always get a blank page with "false" on it
ASKER CERTIFIED SOLUTION
Avatar of rafistern
rafistern

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rafistern - we have been there before - the page will reload

Sorry xabi: this was what I meant - remove the return false and put it in the onClick instead!

<a href="javascript:donothing()" onMouseOver="foo1('resultado');return true" onClick="return false;"><img src="foo.gif"></a>

Michel
Avatar of xabi

ASKER

mplungjam: Ok, it works now but there is still two problems:
1.- onClick doesn't work on IE3
2.- If I click on the image twice Backk button of the naivator must be pressed 3 times :(

Anyway it works
If Michel's answer is better than mine then he can have the points.
What does not work in IE3 (unless your foo1 is an image rollover)? I ran this with the expected results:
<HTML>
<SCRIPT>
function donothing() {;}
function foo1(avalue) { document.theform.thefield.value=avalue;}
</script>
<body>
<a href="javascript:donothing()" onMouseOver="foo1('resultado');return true" onClick="return false;"><img src="foo.gif"></a>
<FORM NAME="theform">
<INPUT TYPE="TEXT" NAME="thefield">
</FORM>
</body>
</HTML>
I use IE3.02, by the way and no extra back click was necessary
Michel
PS: If you want to give us both points, ask customer exchange to help you split them - no extra cost to you...

Michel