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

C

Christopher Nelson

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
 
E

Evertjan.

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>
 
C

Christopher Nelson

VK said:
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).
 
C

Christopher Nelson

Evertjan. said:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:


<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.
 
E

Evertjan.

Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
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.
 
C

Christopher Nelson

Evertjan. said:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:


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.
Why would you do that? That makes no sense at all.

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

Evertjan.

Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
I'll try some other browsers.

Please first try IE.
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?
Because the FAQ I was pointed to above said it's prudent.

Sounds like programming without trying to understand what you do.
 
C

Christopher Nelson

Evertjan. said:
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:


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.
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.
 
E

Evertjan.

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.
 
V

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>
 
C

Christopher Nelson

VK said:
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).
 
D

dx27s

Christopher said:
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.
 
C

Christopher Nelson

dx27s said:
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>
 
L

Lee

Christopher Nelson said:
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>
 
T

Thomas 'PointedEars' Lahn

Christopher said:
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
 
T

Thomas 'PointedEars' Lahn

Christopher said:
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
 
C

Christopher Nelson

Thomas said:
...
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

new rubycam version 0

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top