我是 JavaScript 的初学者,并尝试根据这个Workshop: Displaying a Scrolling Message做简单的核心示例。
但是这个变体滚动消息不起作用。我不明白为什么会这样。我的网络浏览器Google Chrome
,编码ANSI
。
代码:
<html>
<head><title>Scrolling Message Example</title>
<script>
msg = "This is an example of a scrolling message. Isn't it exciting?";
msg = "... ..." + msg;
pos = 0;
function ScrollMessage() {
window.status = msg.substring(pos, msg.length) + msg.substring(0, pos);
pos++;
if (pos > msg.length) pos = 0;
window.setTimeout("ScrollMessage()", 200);
}
ScrollMessage();
</script>
</head>
<body>
<h1>Scrolling Message Example</h1>
Look at the status line at the bottom of this page. (Don't
watch it too long, as it may be hypnotic.)
</body>
</html>
问题:
- 如何解决这个麻烦?
- 哪些其他变体更适合用于此目标?