469,636 Members | 1,952 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

Status bar shows anchor href, not text I set in onmouseover

I have a menu tree made up of anchors inside list items in a
multi-level list that includes HTML like:

<ul id='xx'>
<li><a href='conf.cgi' class='menu' target='main'
title='Configure stuff' onclick='remember("conf.cgi")'
onmouseover='handleOver("Configure stuff")'>Settings</a></li>
</ul>

with the javascript:

function remember(cgi) {
var exp = new Date();
exp.setTime(exp.getTime() + 30 * 24 * 60 * 60 * 1000);
setCookie('lastPage',cgi,exp);
}
function handleOver(text) {
window.status=text;
}

but when I mouse over this, the status bar shows the full path to the
cgi:

http://hostname/cgi-bin/conf.cgi

I've put an alert() into handleOver() so I know it's getting invoked
and my JavaScript console is clean. What am I doing wrong?

While I want a general solution, I'm doing my development and initial
testing on Mozilla 1.7.3.

Any pointers appreciated. Thanks.

Chris

Oct 28 '05 #1
17 4120
VK
> Status bar shows anchor href, not text I set in onmouseover

comp.lang.javascript FAQ (right in front of you):
<http://www.jibbering.com/faq/#FAQ4_35>

Oct 28 '05 #2
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
<a href='conf.cgi' class='menu' target='main'
title='Configure stuff' onclick='remember("conf.cgi")'
onmouseover='handleOver("Configure stuff")'>Settings</a>


<script type="text/javascript">
function setStatus(){
status='Hello world'
}
</script>

<a href='conf.cgi' onmouseout='status=""'
onmouseover='setTimeout("setStatus()",10)'>
Settings</a>
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 28 '05 #3
VK wrote:
Status bar shows anchor href, not text I set in onmouseover


comp.lang.javascript FAQ (right in front of you):
<http://www.jibbering.com/faq/#FAQ4_35>


I've tried several variations on that and none work. The best I've
been able to accomplish is when the mouse enters the anchor the status
bar shows the href and when the mouse leaves the anchor the message I
supply is displayed (until the mouse enters another anchor, of course).

Oct 28 '05 #4
Evertjan. wrote:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
<a href='conf.cgi' class='menu' target='main'
title='Configure stuff' onclick='remember("conf.cgi")'
onmouseover='handleOver("Configure stuff")'>Settings</a>


<script type="text/javascript">
function setStatus(){
status='Hello world'
}
</script>

<a href='conf.cgi' onmouseout='status=""'
onmouseover='setTimeout("setStatus()",10)'>
Settings</a>


Thanks but that's not working for me. The status bar gets cleared on
mouse out but "hello world" never shows up anywhere. Even adding
"return true" to the end of setStatus() didn't help.

Oct 28 '05 #5
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
Evertjan. wrote:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
> <a href='conf.cgi' class='menu' target='main'
> title='Configure stuff' onclick='remember("conf.cgi")'
> onmouseover='handleOver("Configure stuff")'>Settings</a>
<script type="text/javascript">
function setStatus(){
status='Hello world'
}
</script>

<a href='conf.cgi' onmouseout='status=""'
onmouseover='setTimeout("setStatus()",10)'>
Settings</a>


Thanks but that's not working for me. The status bar gets cleared on
mouse out but "hello world" never shows up anywhere.


Works allright under IE6 !

Did you copy/paste my code in an empty html-page?
Even adding
"return true" to the end of setStatus() didn't help.


Why would you do that? That makes no sense at all.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 28 '05 #6
Evertjan. wrote:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
Evertjan. wrote:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:

> <a href='conf.cgi' class='menu' target='main'
> title='Configure stuff' onclick='remember("conf.cgi")'
> onmouseover='handleOver("Configure stuff")'>Settings</a>

<script type="text/javascript">
function setStatus(){
status='Hello world'
}
</script>

<a href='conf.cgi' onmouseout='status=""'
onmouseover='setTimeout("setStatus()",10)'>
Settings</a>
Thanks but that's not working for me. The status bar gets cleared on
mouse out but "hello world" never shows up anywhere.


Works allright under IE6 !


I'll try some other browsers.
Did you copy/paste my code in an empty html-page?


No. I edited it into my CGI.
Even adding
"return true" to the end of setStatus() didn't help.


Why would you do that? That makes no sense at all.


Because the FAQ I was pointed to above said it's prudent.

Oct 28 '05 #7
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
Works allright under IE6 !


I'll try some other browsers.


Please first try IE.
Did you copy/paste my code in an empty html-page?


No. I edited it into my CGI.


Is that the way to conclude "it does not work"?

Please try the above first before expanding a javascript advice into your
own programme.

Does your cgi execute javascript, btw?
> Even adding
> "return true" to the end of setStatus() didn't help.


Why would you do that? That makes no sense at all.


Because the FAQ I was pointed to above said it's prudent.


Sounds like programming without trying to understand what you do.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 28 '05 #8
Evertjan. wrote:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
Works allright under IE6 !
I'll try some other browsers.


Please first try IE.


It works in IE. In Opera, the status bar updates as desired but the
tooltip shows the Title and the Address. In Firefox, as in Mozilla,
the address is shown in the status bar and I don't seem to be able to
change that.
Did you copy/paste my code in an empty html-page?


No. I edited it into my CGI.


Is that the way to conclude "it does not work"?


It didn't work for me in my CGI in the broswer I was using.
Please try the above first before expanding a javascript advice into your
own programme.

Does your cgi execute javascript, btw?
My CGI has a ton of JavaScript in it.
...


I don't know that I'll do better than what I have. I'd really like to
fix the status bar in Mozilla and Firefox if I could but I don't know
what the problem is.

Oct 28 '05 #9
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
I don't know that I'll do better than what I have. I'd really like to
fix the status bar in Mozilla and Firefox if I could but I don't know
what the problem is.


I'm sorry, I am not an expert there.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Oct 28 '05 #10
VK
> Status bar shows anchor href, not text I set in onmouseover

OK - maybe making it as a puzzle will finally attract you to *read* the
suggested FAQ

Read it *through* again and try to find the condition missing in your
script. Theanswer is given below the FAQ's link (ROT 13 encoded).

FAQ 4.35
<http://www.jibbering.com/faq/#FAQ4_35>

<ANSWER: ROT 13>
lbh fubhyq erghea gehr sebz gur rirag
</ANSWER: ROT 13>

Oct 28 '05 #11
VK wrote:
Status bar shows anchor href, not text I set in onmouseover


OK - maybe making it as a puzzle will finally attract you to *read* the
suggested FAQ

Read it *through* again and try to find the condition missing in your
script. Theanswer is given below the FAQ's link (ROT 13 encoded).

FAQ 4.35
<http://www.jibbering.com/faq/#FAQ4_35>

<ANSWER: ROT 13>
lbh fubhyq erghea gehr sebz gur rirag
</ANSWER: ROT 13>


Yes, that's one of the changes I made. Having reviewed the FAQ, I

1) used setTimeout to delay setting the status, and

2) returned true from the event handler.

My code now looks like:

function setStatus(text) {
var a ='window.status=\''+text+'\'';
setTimeout(a,15);
return true;
}
function clearStatus() {
window.status=''
return true;
}

and the HTML looks like:

<li><a href='sysconf.cgi' class='menu' target='main'
title='Configure stuff'
onmouseout='clearStatus()'
onmouseover='setStatus("Configure stuff")'>Settings</a></li>

This seems to be fine in IE and Opera but now with Firefox or Mozilla
(where the href shows up, not the desired text).

Oct 28 '05 #12
Christopher Nelson wrote:

I don't know that I'll do better than what I have. I'd really like to
fix the status bar in Mozilla and Firefox if I could but I don't know
what the problem is.


The default settings in Firefox prevent you from changing the status bar
text. Go to Preferences -> Web Features -> Enable Javascript ->
Advanced... and make sure "Change status bar text" is checked.
Oct 28 '05 #13
dx27s wrote:
Christopher Nelson wrote:

I don't know that I'll do better than what I have. I'd really like to
fix the status bar in Mozilla and Firefox if I could but I don't know
what the problem is.


The default settings in Firefox prevent you from changing the status bar
text. Go to Preferences -> Web Features -> Enable Javascript ->
Advanced... and make sure "Change status bar text" is checked.


Thanks but even with that enabled, the status bar still shows the href,
not my text. I'm using Firefox v1.0.1, if that matters. <shrug>

Oct 28 '05 #14
Lee
Christopher Nelson said:

dx27s wrote:
Christopher Nelson wrote:
>
> I don't know that I'll do better than what I have. I'd really like to
> fix the status bar in Mozilla and Firefox if I could but I don't know
> what the problem is.


The default settings in Firefox prevent you from changing the status bar
text. Go to Preferences -> Web Features -> Enable Javascript ->
Advanced... and make sure "Change status bar text" is checked.


Thanks but even with that enabled, the status bar still shows the href,
not my text. I'm using Firefox v1.0.1, if that matters. <shrug>


With changing the status bar enabled, the following works for
me in Firefox 1.0.7:

<html>
<body>
<script type="text/javascript">
function handleOver(text) {
window.status=text;
}
</script>
<a href="#" onmouseover="handleOver('my message');return true">Demo</a>
</body>
</html>

Oct 28 '05 #15
Christopher Nelson wrote:
My code now looks like:

function setStatus(text) {
var a ='window.status=\''+text+'\'';
setTimeout(a,15);
Timeouts/intervalls less than 25 *milli*seconds are seldom reliable, and

setTimeout("window.status = '" + text + "';", 25);

will suffice.
[...]
and the HTML looks like:

<li><a href='sysconf.cgi' class='menu' target='main'
Think about if the `target' attribute is really necessary. If it is for
frames, think about replacing frames by block elements positioned with CSS.
title='Configure stuff'
onmouseout='clearStatus()'
onmouseover='setStatus("Configure stuff")'>Settings</a></li>

This seems to be fine in IE and Opera but now with Firefox or Mozilla
(where the href shows up, not the desired text).


You have probably set the preference that disallows scripts to manipulate
the content of the status bar (in Firefox: Edit/Tools, Preferences, Web
Features, Enable JavaScript, Advanced, [_] Change status bar text). That
said, you should almost never mess with the status bar, definitely not
here.
PointedEars
Oct 28 '05 #16
Christopher Nelson wrote:
dx27s wrote:
Christopher Nelson wrote:
> I don't know that I'll do better than what I have. I'd really like to
> fix the status bar in Mozilla and Firefox if I could but I don't know
> what the problem is.
The default settings in Firefox prevent you from changing the status bar
text. Go to Preferences -> Web Features -> Enable Javascript ->
Advanced... and make sure "Change status bar text" is checked.


Thanks but even with that enabled, the status bar still shows the href,
not my text. I'm using Firefox v1.0.1, if that matters. <shrug>


The following works for me in

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922
Firefox/1.0.7 (Debian package 1.0.7-1) Mnenhy/0.7.2.0

(and other UAs) if the above pref is enabled:

function setStatus(o, bHideURI)
{
var s = o.title;

if (!bHideURI && typeof o.href != "undefined")
{
s += " (" + o.href + ")";
}

window.status = s;
return true;
}

function resetStatus()
{
window.status = window.defaultStatus;

return true;
}

HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- missing system identifier triggers Quirks Mode -->
[...]
<a href="main.en.php" title="Display&nbsp;Language: English"
onmouseover="return setStatus(this)" onmouseout="resetStatus()"English</a>

HTH

PointedEars
Oct 28 '05 #17
Thomas 'PointedEars' Lahn wrote:
...
The following works for me in

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922
Firefox/1.0.7 (Debian package 1.0.7-1) Mnenhy/0.7.2.0

(and other UAs) if the above pref is enabled:

function setStatus(o, bHideURI)
{
var s = o.title;

if (!bHideURI && typeof o.href != "undefined")
{
s += " (" + o.href + ")";
}

window.status = s;
return true;
}

...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- missing system identifier triggers Quirks Mode -->
[...]
<a href="main.en.php" title="Display&nbsp;Language: English"
onmouseover="return setStatus(this)" onmouseout="resetStatus()"
>English</a>


Cool. I like using o.title for the status bar. Thanks.

Oct 31 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Ian Shere | last post: by
10 posts views Thread by Frances Del Rio | last post: by
2 posts views Thread by Xerxes | last post: by
2 posts views Thread by NielsM | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.