FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar change?

F

FAQ server

-----------------------------------------------------------------------
FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar change?
-----------------------------------------------------------------------

When changing the status in an event (e.g. onmouseover) you
should return true from the event. Also a number of browsers
require a short delay before setting the status to overcome their
default behaviour with the statusbar. «
onevent="setTimeout('window.status=\'Moomin\'',15);" »
Some browsers may be configured to disallow scripts from setting
the status.


===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://www.jibbering.com/faq/.
The FAQ workers are a group of volunteers.
 
E

Evertjan.

FAQ server wrote on 17 sep 2006 in comp.lang.javascript:
-----------------------------------------------------------------------
FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar
change?
-----------------------------------------------------------------------

When changing the status in an event (e.g. onmouseover) you
should return true from the event. Also a number of browsers
require a short delay before setting the status to overcome their
default behaviour with the statusbar. ®
onevent="setTimeout('window.status=\'Moomin\'',15);" ¯
Some browsers may be configured to disallow scripts from setting
the status.

Why not specify the different browser's behavour?

If we are at it why not incorporate the behavour of
window.title = "Moomin"
?

========

I could imagine building a browser that specificly disallows
the status bar to contain "Moomin".
 
V

VK

From the *event handler itself* and not from a function called by this
handler. The most often mistake was:

<html>
<head>
<title>window.status demo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">

function setStatus(message) {
window.status = message;
return true;
}

</script>
</head>

<body>
<p>
<a href="noscript.html"
onMouseOver="setStatus('a JavaScript call');"
onMouseOut="setStatus(window.defaultStatus);"
onClick="window.alert('a JavaScript call'); return false;">Wrong
status set demo</a>
</p>
</body>
</html>

That seems that setStatus return true as requested yet status change
doesn't work. This is because out intrinsic handler is in fact an
anonymous function calling setStatus(), so we have:
function anonymous() {
setStatus('a JavaScript call');
}
and respectively we do not return any true from that anonymous
function. The proper way is:

<html>
<head>
<title>window.status demo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">

function setStatus(message) {
window.status = message;
return true;
}

</script>
</head>

<body>
<p>
<a href="noscript.html"
onMouseOver="return setStatus('a JavaScript call');"
onMouseOut="return setStatus(window.defaultStatus);"
onClick="window.alert('a JavaScript call'); return false;">Right
status set demo</a>
</p>
</body>
Also a number of browsers
require a short delay before setting the status to overcome their
default behaviour with the statusbar.
onevent="setTimeout('window.status=\'Moomin\'',15);"

Besides it is not a working sample whatsoever (no true return value):
which browsers require such delay?
Some browsers may be configured to disallow scripts from setting
the status.

Full ACK, and more and more of them: as the status message change is
one of common annoyances and a potential security risk (links fraud).

Yet if we give a sample of use, let's make it at least properly working
(where allowed).

All possible usage methods (on UA's where not blocked):

<html>
<head>
<title>window.status demo</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function setStatus(message) {
window.status = message;
return true;
}

function init() {
var p = document.getElementById('p04');
p.onmouseover = function() {
window.status = 'a JavaScript call';
return true;
}
p.onmouseout = function() {
window.status = window.defaultStatus;
return true;
}
p.onclick = function() {
window.alert('a JavaScript call');
return false;
}
}

window.onload = init;
</script>
</head>

<body>
<p>
<a href="noscript.html"
onMouseOver="window.status = 'a JavaScript call'; return true;"
onMouseOut="window.status = window.defaultStatus; return true;"
onClick="window.alert('a JavaScript call'); return false;">Intrinsic
handler demo</a>
</p>

<p>
<a href="noscript.html"
onMouseOver="return setStatus('a JavaScript call');"
onMouseOut="return setStatus(window.defaultStatus);"
onClick="window.alert('a JavaScript call'); return false;">Function
call demo</a>
</p>

<p>
<a href="noscript.html"
onMouseOver="setStatus('a JavaScript call');"
onMouseOut="setStatus(window.defaultStatus);"
onClick="window.alert('a JavaScript call'); return false;">Wrong
function call demo</a>
</p>

<p id="p04">Programmatically attached handler demo</p>
</body>
</html>
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top