Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / October 2005



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christopher Nelson - 28 Oct 2005 13:49 GMT
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
VK - 28 Oct 2005 13:59 GMT
> 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>
Christopher Nelson - 28 Oct 2005 14:27 GMT
> > 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).
Evertjan. - 28 Oct 2005 14:18 GMT
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>

Signature

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

Christopher Nelson - 28 Oct 2005 14:36 GMT
> Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
>
[quoted text clipped - 11 lines]
> 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.
Evertjan. - 28 Oct 2005 14:42 GMT
Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:

>> Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
>>
[quoted text clipped - 14 lines]
> 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.

Signature

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

Christopher Nelson - 28 Oct 2005 14:54 GMT
> Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
>
[quoted text clipped - 18 lines]
>
> 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.
Evertjan. - 28 Oct 2005 15:03 GMT
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.

Signature

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

Christopher Nelson - 28 Oct 2005 15:45 GMT
> Christopher Nelson wrote on 28 okt 2005 in comp.lang.javascript:
>
[quoted text clipped - 3 lines]
>
> 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.
Evertjan. - 28 Oct 2005 15:49 GMT
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.

Signature

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

VK - 28 Oct 2005 16:44 GMT
> 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>
Christopher Nelson - 28 Oct 2005 18:18 GMT
> > Status bar shows anchor href, not text I set in onmouseover
>
[quoted text clipped - 10 lines]
> 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).
Thomas 'PointedEars' Lahn - 28 Oct 2005 21:44 GMT
> 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
dx27s - 28 Oct 2005 19:26 GMT
> 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.
Christopher Nelson - 28 Oct 2005 19:42 GMT
> > 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
[quoted text clipped - 3 lines]
> 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>
Lee - 28 Oct 2005 20:35 GMT
Christopher Nelson 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
[quoted text clipped - 6 lines]
>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>
Thomas 'PointedEars' Lahn - 28 Oct 2005 21:50 GMT
>> > 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
[quoted text clipped - 6 lines]
> 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
Christopher Nelson - 31 Oct 2005 15:10 GMT
> ...
> The following works for me in
[quoted text clipped - 24 lines]
>    onmouseover="return setStatus(this)" onmouseout="resetStatus()"
>    >English</a>

Cool.  I like using o.title for the status bar.  Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.