Thursday
August 21, 2014

Homework Help: JAVASCRIPT

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

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

Answer this Question

First Name:
School Subject:
Answer:

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...

Search
Members