Thursday

August 21, 2014

August 21, 2014

Posted by **Kevin** on Thursday, April 21, 2011 at 8:57pm.

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

}

}

- JAVASCRIPT -
**MathMate**, Thursday, April 21, 2011 at 10:36pmUnfortunately 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

**Related Questions**

Javascript - How do take this following javascript and put in external ...

Javascript - I would like the function test to get the input from the user and ...

programming - JavaScript - /*Hello, I really hope someone can help me out with ...

Statistics - Joint probability density function is: x + y where 0<x<1 and ...

statistics - The profit for a new product is given by Z = 2X - 2Y - 7. We know ...

Computer Science - Suppose X is a random variable and Y = aX + b is a linear ...

financial statistics - Can you construct a pair of random variables such that ...

statistics - GIVEN THE FOLLOWING STATISTICAL VARIABLES A:m(A)=5 B:m(B)=13 var(A...

JavaScript - I'm working on a javascript exercise. I have written function ...

Javascript - I need help these javascript exericses: Input: A text string, using...