Solved

javascript null function.

Posted on 1998-09-09
9
6,542 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:xabi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1270524
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
0
 
LVL 8

Author Comment

by:xabi
ID: 1270525
I always get a blank page with "false" on it
0
 
LVL 4

Accepted Solution

by:
rafistern earned 50 total points
ID: 1270526
how about
<a href="" onMouseOver="foo1('resultado');return true">
or
<a href="#" onMouseOver="foo1('resultado');return true">

without any need for a null function.

0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1270527
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
0
 
LVL 8

Author Comment

by:xabi
ID: 1270528
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
0
 
LVL 4

Expert Comment

by:rafistern
ID: 1270529
If Michel's answer is better than mine then he can have the points.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1270530
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>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1270531
I use IE3.02, by the way and no extra back click was necessary
Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1270532
PS: If you want to give us both points, ask customer exchange to help you split them - no extra cost to you...

Michel
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Building JSON/JQuery Results Display 11 55
HTML editor custom button 3 88
How can I allow 0, 10 or 13 digits only with regular expression/javascript 2 46
Diff of the day 2 43
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question