By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

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

P: n/a
-----------------------------------------------------------------------
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.

Sep 16 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"FAQ server" <ja********@dotinternet.bewrote in news:450c81f6$0$75035
$1*******@news.sunsite.dk:
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) ;"
Well, if "you should return true from the event" shouldn't the example show
that?
Sep 17 '06 #2

P: n/a
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".

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 17 '06 #3

P: n/a
VK

FAQ server wrote:
-----------------------------------------------------------------------
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.
>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>
</html>
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>

Sep 17 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.