JAVASCRIPT

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. 👍
  2. 👎
  3. 👁
  1. 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

    1. 👍
    2. 👎

Respond to this Question

First Name

Your Response

Similar Questions

  1. Ed Tech

    What does the code of conduct include? A. A secret code for internet users B. The conduct that should be used with a code C. A set of rules for behavior when using the internet D. A rule that tells you the code I think C Thanks!

  2. math

    Zip code contains 4 digits. How many zip-codes can be created with digits 0−9 if you can use each digit only once and zip code can not start with 0.

  3. Computer Literary

    Which of the following is Not an example of debugging A)Looking for errors in programming code B)Fixing misspelled commands in programming code C)Solving faulty logic in programming code D)Upgrading to improve the programming code

  4. Physics

    A ball is thrown vertically upward from a window with an initial velocity of 10m/s. if it hits the ground below the window 5.0s later, what is the height of the window...can you tell me the steps on how to do this please...

  1. Math

    The Cougars won 62% of their games. They won 93 games. How many games did they lose? I'm not exactly sure how to approach this I tried to divide 93 by .62 but that didn't quite exactly work out and I'm not sure how to find the

  2. math

    For a button to fit through its buttonhole, the hole needs to be the size of the button's diameter. What size buttonhole is needed for a button with a circumference of 7.38 centimeters? (Use the value of 3.14 to represent pi.) A.

  3. Math

    A Norman window has the shape of a rectangle surmounted by a semicircle. If the perimeter of the window is 26 ft, express the area A of the window as a function of the width x of the window.

  4. Calc

    A Norman window is constructed by adjoining a semicircle to the top of a rectangular window as shown in the figure below. If the perimeter of the Norman window is 24 ft, find the dimensions that will allow the window to admit the

  1. Differential Calculus

    A norman window has the shape of a rectangle surmounted by a semicircle. If the perimeter of the window 10 m, express the area A of the window as the function of width x of the window.

  2. Calculus 1

    A Norman window has the shape of a rectangle surmounted by a semicircle. If the perimeter of the window is 32 ft, express the area A of the window as a function of the width x of the window.

  3. History

    The Code Talkers were members of which Native American tribe? Apache Hopi Navajo******** Pueblo 2. Why was the Code Talkers' code so hard to break? It was based on a language that lacked an alphabet and was hard to learn. The

  4. Ed Tech

    When you see pop-ups while working on the computer, what should you do?( 1 point) A. Always click No. B. Read the text, and then choose the appropriate response.( my answer) C. Click outside the pop-up window to make the window

You can view more similar questions or ask a new question.