Forum Moderators: open

Message Too Old, No Replies

Display custom window status message - works in Firefox and IE 7

For JavaScript links only, put your message in the href

         

Brad_H

3:57 am on Apr 3, 2007 (gmt 0)

10+ Year Member



Newer browsers are now preventing you from setting the text in the status bar from JavaScript.

Instead of using onmouseover and onmouseout, I've been putting the text I want to display in the status bar into the href. (This works for JavaScript links only!)

<a href="status-prefix: Enter your status bar message here" onclick="alert('put your JavaScript here');return false">Mouseover to see status bar text</a>

You need to have a colon in the href before you enter any spaces. This is needed to make the browser think it is a real URL using a custom protocol.

What do you think of this method? Could it cause any problems?

keyplyr

8:00 am on Apr 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




This works in FF. It works in IE6, but not IE7:

window.status="message here";

Brad - How would you write your code so I could use it as an external JS to put a message in the status bar for both FF and IE7?

Brad_H

1:27 pm on Apr 3, 2007 (gmt 0)

10+ Year Member



The method I described above does not use JavaScript to put the message in the status bar. It has been recommended by tedster [webmasterworld.com] that you shouldn't manually over-ride the message bar.

My method works because you are linking directly to the text of the message you want in the status bar, and browsers will show your message as the URL. The trick to making this work is having a short prefix with a colon, this makes it so it doesn't display http;//www.yourwebsite.com/dir/ at the beginning of the url.

Fotiman

6:34 pm on Apr 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Newer browsers are now preventing you from setting the text in the status bar from JavaScript.

And with good reason. As tedster exlpained in the link above, you shouldn't over-ride the status bar. Users are expecting a certain behavior from their browser, so it's not a good idea to change that.


It has been recommended by tedster that you shouldn't manually over-ride the message bar.

And yet you still are.


My method works because you are linking directly to the text of the message you want in the status bar, and browsers will show your message as the URL.

Which, again, is NOT the behavior a user will expect.

keyplyr

10:57 pm on Apr 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Actually, the example I gave does not override the browser's default status bar message. It appears after (instead of the word "done." I use it in various capacities, all related to giving useful info to the end user.

Fotiman

3:05 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Actually, the example I gave does not override the browser's default status bar message.

For hyperlinks, the browsers default status message is to show the URL. You are not showing a URL, therefore you ARE overriding the browsers default status bar message.

keyplyr

5:33 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



And you are missing the point :)

All URLs are shown as expected, as are all other browser messages.

Fotiman

5:40 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Maybe I'm misunderstanding you then. Can you provide a real world example, using the actual values that one might use?

[edited by: Fotiman at 5:41 pm (utc) on April 4, 2007]

Fotiman

6:15 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I got your sticky message with the live example. In your case, you are using it in a "tab-like" navigation, where clicking on a tab would make that tab "active", and hovering over a tab would show a message in the status bar like "menu-change: Advanced Font Settings".

However...

Your approach has one major flaw. A user that has JavaScript disabled will not be able to see the contents of your tab. Clicking on the tab will result in an error like:

Firefox doesn't know how to open this address, because the protocol (menu-change) isn't associated with any program

In other words, instead of taking a "progressive enhancement" approach, where the core content is always available no matter what user agent is used or what technologies are available, you have made JavaScript a requirement.

A better approach would be to develop your tabs using semantic markup. For example:


<ul>
<li><a href="#AdvancedFontSettings">Font Settings</a></li>
<li><a href="#BorderSettings">Border Settings</a></li>
</ul>
<div id="AdvancedFontSettings">...</div>
<div id="BorderSettings">...</div>

Then use progressive enhancement techniques to turn this into a tabbed structure, so it's accessble whether or not the user has JavaScript.

If you're set against making your site/application available to everyone, then maybe instead of using "menu-change: " as the prefix, perhaps you could using "#"? While it still wouldn't work in your example for sites with JavaScript disabled, I suspect it would at least prevent an ugly error message about an unknown protocol.

Brad_H

7:14 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



Javascript will be required for this part of the site (not the entire site).

I added a message to the page than Javascript is required.

If I use "#" it adds the the the full url as the prefix. I would rather have the status bar show "menu-change: Advanced Font Settings" than show "http : //www.mydomainname.com/dir/my-url-can-be-very-long.htm#AdvancedFontSettings"

Fotiman

7:30 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In that case, what about doing something like this:

<a href="javascript:// Test Me">Test</a>

This will display in the status bar as:

javascript:// Test Me

Clicking on the link when JavaScript is disabled will not cause an ugly error about an unknown protocol.

Brad_H

7:56 pm on Apr 4, 2007 (gmt 0)

10+ Year Member



That would work. It doesn't look quite as nice in the status bar, but it's good enough.

jdMorgan

9:19 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or how about a tool-tip instead:

<li title="Advanced font selection">Font Settings</li>

That avoids the whole "trust issue" involved with changing the status bar, and puts the explanation at the visitor's visual point of focus.

Just a note that disabling status bar text changes is one of the things that's an easy option in Firefox, and I do exactly that so as to easily reveal phishing sites. You can do what you like on-page, but I no longer allow sites to mess with my chrome.

Jim

Fotiman

4:54 pm on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Duh! A tooltip! So obvious, it should have been my first suggestion. :-) Great advice. Rather than try and monkey around with the status bar, a tooltip is a much better place to put this info.