Asked by Kevin
Start button won't work for a scolling marquee. Below is the javascript code.
window.onload = defineMarquee;
var timeID;
var marqueeTxt = new Array;
var marqueeOff = true;
function defineMarquee() {
var topValue = 0;
var allElems = document.getElementsByTagName("*");
for (var i = 0; i < allElems.length; i++) {
if (allElems[i].className == "marqueeTxt") marqueeTxt.push(allElems[i]);
}
for (var i = 0; i < marqueeTxt.length; i++) {
if (window.getComputedStyle) {
topValue = marqueeTxt[i].document.defaultView.getPropertyValue("top");
}
else if (marqueeTxt[i].currentStyle) {
topValue = marqueeTxt[i].currentStyle("top");
}
}
document.getElementById("startMarquee").onclick = startMarquee;
document.getElementById("stopMarquee").onclick = stopMarquee;
}
function startMarquee() {
if (marqueeOff == true) {
timeID = setInterval("moveMarquee()", 50);
marqueeOff = false;
}
}
function stopMarquee() {
clearInterval(timeID);
marqueeOff = true;
}
function moveMarquee() {
var topPos = 0;
for (var i = 0; i < marqueeTxt.length; i++) {
if(marqueeTxt[i].getComputedStyle){
topPos = parseInt(marqueeTxt[i].getPropertyValue("top"));
}
else
if(marqueeTxt[i].currentStyle) {
topPos = parseInt(marqueetxt[i].currentStyle("top"));
}
if(topPos < -110) {
topPos = 700;
}
else {
topPos -= 1;
}
marqueeTxt[i].style.top = topPos + "px";
}
}
window.onload = defineMarquee;
var timeID;
var marqueeTxt = new Array;
var marqueeOff = true;
function defineMarquee() {
var topValue = 0;
var allElems = document.getElementsByTagName("*");
for (var i = 0; i < allElems.length; i++) {
if (allElems[i].className == "marqueeTxt") marqueeTxt.push(allElems[i]);
}
for (var i = 0; i < marqueeTxt.length; i++) {
if (window.getComputedStyle) {
topValue = marqueeTxt[i].document.defaultView.getPropertyValue("top");
}
else if (marqueeTxt[i].currentStyle) {
topValue = marqueeTxt[i].currentStyle("top");
}
}
document.getElementById("startMarquee").onclick = startMarquee;
document.getElementById("stopMarquee").onclick = stopMarquee;
}
function startMarquee() {
if (marqueeOff == true) {
timeID = setInterval("moveMarquee()", 50);
marqueeOff = false;
}
}
function stopMarquee() {
clearInterval(timeID);
marqueeOff = true;
}
function moveMarquee() {
var topPos = 0;
for (var i = 0; i < marqueeTxt.length; i++) {
if(marqueeTxt[i].getComputedStyle){
topPos = parseInt(marqueeTxt[i].getPropertyValue("top"));
}
else
if(marqueeTxt[i].currentStyle) {
topPos = parseInt(marqueetxt[i].currentStyle("top"));
}
if(topPos < -110) {
topPos = 700;
}
else {
topPos -= 1;
}
marqueeTxt[i].style.top = topPos + "px";
}
}
Answers
Answered by
MathMate
Unfortunately the above code does not contain all the necessary elements for a test.(E.g. the marqueeTxt elements, and the start/stop buttons).
I'm not familiar with marquees in Javascript. However, I've tested an example code that actually works without changing an iota. You could give it a try and see if it helps.
http://javascript.about.com/library/bltick2.htm
I'm not familiar with marquees in Javascript. However, I've tested an example code that actually works without changing an iota. You could give it a try and see if it helps.
http://javascript.about.com/library/bltick2.htm
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.