File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Question on MouseOver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Question on MouseOver" Watch "Question on MouseOver" New topic

Question on MouseOver

Bhaswati Karmakar
Ranch Hand

Joined: May 10, 2001
Posts: 32
I have a text eg. "Test". When I bring the mouse over it, I want to display "Test Now".
How can I do this? I would like to use onMouseOver and not HTML's tool tip.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
in order for onmouseover to work you have to define it within an html element like <P> or <A> or any of the other that support onmouseover. something like this:
<p onmouseover='mouseOverfunction()>this is my test text</p>
then define your function something along these lines:
function mouseOverfunction(){
alert("you moused over my test text");
if you dont want the alert box (and beep) you can use the status bar like this:
window.status="you moused over the test text!";
I dont know if there is a way to get a tooltip like appearance though, but either of these should work for you.
hope that helps

Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
this is the code you need:

<script language="javascript">
function now()
document.write("test now");
<body bgcolor="#FFFFFF" text="#000000">
<a href="#" OnmouseOver="now()">test </a>

The word test must be a link to invoke javascript function. If you want it to look like normal text you can use CSS to do that OR if it's a link and you want "Test now" to be a link too just include the HTML tags in the document.write brackets.

Raising Flares debut album 'Ignition' out now

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Conrad Kirby
Ranch Hand

Joined: Jun 17, 2001
Posts: 178
What you are asking for doesn't seem like like a good idea, unless you were to display the resulting text in the status bar. Constanly alerting the user or writing text to the screen can become a real pain. Also, writing text to the screen may not work since you would be writing text outside of the <body> and <html> tags. The status bar is the best way to go.
Mkhaya Tini

Joined: Oct 06, 2005
Posts: 23
digging up this old thread because my question is on the same line.

I've a table. Each cell contains a link. when i take the mouse to the link it shows the javascript function it will call including the value. since the value is big and contains html code, the status bar becomes full of junk. i mean it does not look good. so, i was trying to use OnMouseOver and window. status to show a clean text there such as "click here to do this or that". something like

< a href="javascript:someFunction(someVar)" onMouse0ver="javascript:changeStatus()" >..............

function changeStatus(){
window. status = "Text goes here";

problem is, i can see both. when the mouse is on side the cell but not on the link, i see "text goes here". but when the mouse is on the link i can see what I want to hide.

is there any way to do what i'm trying to do? if yes, what. thanks.
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
If instead of putting your Javascript function in the href, you put it in onc1ick, the browser shouldn't display it in the status bar.
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
look at:

Mkhaya Tini

Joined: Oct 06, 2005
Posts: 23
thanks Eric, but I already implimented it using Garann Means's method. so, thanks both of you.
I agree. Here's the link:
subject: Question on MouseOver
jQuery in Action, 3rd edition