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

error in code

P: n/a
I have a script to display a moving text in the status bar. I also
want to display the change of ShowHead and ShowTail variables in the
page. I wrote a
function w()to do this. But it caused an error after it ran. Could
you tell me what is wrong? Thanks a lot.
Here is the code:
<html>
<head>
</head>
<body><script>
var ShowString = " " //The
first line must be blank
+ "JavaScript Scrolling Text Demo is here... "
var ShowWidth = 1000
var ShowHead = 0
var ShowTail = ShowWidth
var ShowLength = ShowString.length

function Marquee(){
var DisplayString
if (ShowHead < ShowTail)
DisplayString = ShowString.substring(ShowHead, ShowTail)
else
DisplayString = ShowString.substring(ShowHead, ShowLength)
+ ShowString.substring(0, ShowTail)
ShowHead = (ShowHead + 1 ) % ShowLength
ShowTail = (ShowTail + 1 ) % ShowLength
window.status = DisplayString
TimerID = setTimeout("Marquee()",200)
}
Marquee();//above is OK.
function w(){
document.write(ShowHead +" "+ ShowTail);
setTimeout("w()",200);
}
w();
</script>
</body>
</html>
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
chirs wrote:
I have a script to display a moving text in the status bar.
Remove it, for the sake of your visitors and for your own sake.
The status bar is a useful tool and you should not touch it,
unless you know what you are doing (which is obviously not the
case.)
I also want to display the change of ShowHead and ShowTail variables
in the page. I wrote a function w()to do this.
Once a document has been loaded, document.write(...) overwrites the
document which causes all variables and functions to be undefined.
Use DOM scripting instead of document.write(...) if you need a timed
presentation.
But it caused an error after it ran.
`An error occured' is an insufficient error *description*.
[...]
<html>
Before this tag the DOCTYPE declaration is missing.
<head>
</head>
The charset declaration via the `meta' element,
and the `title' element are missing here.
<body><script>
The `type' attribute for the `script' element is missing.
It should be at least <script type="text/javascript">.

Your markup is invalid. See http://validator.w3.org/ for details.
[...]
function w(){
document.write(ShowHead +" "+ ShowTail);
setTimeout("w()",200);
}
w();
[...]

PointedEars

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.