Dragonfish
Programmer
I´m trying this scroller I found in a book. I made a minor change in that I put the entire code into an external js. script. I´ve added some document.write(); to see where the thing crashes and it does´nt like pos++; here´s the text:
function TextScroller() {
var scrollmessage=" *** Dies ist ein Testtext *** Dies ist ein 2 Testtext *** Dies ist ein 3 Testtext";
var textlength = scrollmessage.length;
var textwidth = 50;
var pos = -(textwidth + 2);
document.write(scrollmessage + "<br>"
;
document.write(textlength + "<br>"
;
document.write(textwidth + "<br>"
;
document.write(pos + "<br>"
;
ScrollStatus();
}
function ScrollStatus() {
document.write("hallo<br>"
;
pos++;
document.write(pos);
var scroller = " ";
if (pos == textlength) {
pos = -(textwidth + 2);
}
if (pos < 0) {
for (var i = 1; i <= math.abs(pos); i++) {
// Leerzeichen einfügen
scroller = scroller + " ";
}
scroller = scroller + scrollmessage.substring(0, textwidth - i + 1);
}
else {
scroller = scroller + scrollmessage.substring(pos, textwidth + pos);
}
window.status = scroller;
setTimeout("Scroll()", 1000);
}
IE says the error was in line 16 - object expected. the js. is called with <body onLoad="TextScroller()"> I´m wondering wether the first function is parsing the content of pos to the second function but I´m new to JavaScript so I´d appreciate some help - thanks DavidinGermany
function TextScroller() {
var scrollmessage=" *** Dies ist ein Testtext *** Dies ist ein 2 Testtext *** Dies ist ein 3 Testtext";
var textlength = scrollmessage.length;
var textwidth = 50;
var pos = -(textwidth + 2);
document.write(scrollmessage + "<br>"
document.write(textlength + "<br>"
document.write(textwidth + "<br>"
document.write(pos + "<br>"
ScrollStatus();
}
function ScrollStatus() {
document.write("hallo<br>"
pos++;
document.write(pos);
var scroller = " ";
if (pos == textlength) {
pos = -(textwidth + 2);
}
if (pos < 0) {
for (var i = 1; i <= math.abs(pos); i++) {
// Leerzeichen einfügen
scroller = scroller + " ";
}
scroller = scroller + scrollmessage.substring(0, textwidth - i + 1);
}
else {
scroller = scroller + scrollmessage.substring(pos, textwidth + pos);
}
window.status = scroller;
setTimeout("Scroll()", 1000);
}
IE says the error was in line 16 - object expected. the js. is called with <body onLoad="TextScroller()"> I´m wondering wether the first function is parsing the content of pos to the second function but I´m new to JavaScript so I´d appreciate some help - thanks DavidinGermany