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";
}
}

1 answer

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
Similar Questions
    1. answers icon 1 answer
  1. The maximize button is used to:Expand a window to fill the entire screen Scroll slowly through a window Reduce a window to a
    1. answers icon 1 answer
  2. What will be the value of sum after this code runs?var START = 1; var END = 4; function start(){ var sum = 0; for(var i = START;
    1. answers icon 1 answer
  3. Why do some programmers begin by creating empty functions?(1 point) Responses It can make the code better organized. It can make
    1. answers icon 1 answer
more similar questions