posted by .

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() {
marqueeOff = true;

function moveMarquee() {

var topPos = 0;

for (var i = 0; i < marqueeTxt.length; i++) {
topPos = parseInt(marqueeTxt[i].getPropertyValue("top"));
if(marqueeTxt[i].currentStyle) {
topPos = parseInt(marqueetxt[i].currentStyle("top"));
if(topPos < -110) {
topPos = 700;
else {
topPos -= 1;
marqueeTxt[i] = topPos + "px";


    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.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Statistics

    Joint probability density function is: x + y where 0<x<1 and 0<y<1 (0 elsewhere) Find variance of (30x + 25y) Answer is 11.48 --- My calculations Marginal probability density functions (same for x and y): f(x) = x + 1/2 …
  2. programming - JavaScript

    /*Hello, I really hope someone can help me out with this function. I'm a newbie to JavaScript. I have included the instructions for the swapFE() function that I have to complete below along with the functions that I have done so far. …
  3. financial statistics

    Can you construct a pair of random variables such that Var(X)=Var(Y)=1 and Cov(X,Y)=2?
  4. statistics

    The profit for a new product is given by Z = 2X - 2Y - 7. We know that X and Y are independent random variables with Var(X) = 2 and Var(Y) = 2.7. What is the variance of Z?
  5. Javascript

    How do take this following javascript and put in external javascript. <html> <head> <script language="javascript" type="text/javascript"> test(); function counter(array){ var negatives =0; var zeroes =0; var positives=0 …
  6. Javascript

    I would like the function test to get the input from the user and display the like the counter function and to display if it passed or not. var negatives =0; var zeroes =0; var positives=0 ; function counter(array){ var i=0; for(i=0;i<array.length;i++) …
  7. Computer Science

    Suppose X is a random variable and Y = aX + b is a linear function of X. Show that the correlation of X and Y is -1 if a < 0. cor(X,Y) = cov(X,V)/ sqrt(var(X)*var(Y))
  8. Computer science

    I want to make my traffic lights run automatically without any user input. I have created this code so far but the images don't show up please help. My code: <!DOCTYPE html> <html> <head> <script type="text/javascript"> …
  9. Stat & Prob.

    Show that if Cov(X,Y)=0, then the correlation coefficient satisfies p(X+Y, X-Y)=Var(X)-Var(Y)/ Var(X)+Var (Y)
  10. College Stats

    Suppose that two random variables X1 and X2 have a bivariate normal distribution, and Var(X1) = Var(X2). Show that the sum X1+X2 and the difference X1− X2 are independent.

More Similar Questions