Hi,
Maybe if you think of this problem in another way:
a) You want a news to appear every - say - 10 seconds....
This will allow you to use the setTimeout in javascript:
<script language="javascript">
var myNewsTimer = '';
var myNewsIndex = 0;
var myNewsCounter = 2;
var myNewsArray = new Array();
myNewsArray[0] = "<strong>Princes Margeret is dead</strong><p>(CNN) --
Princess Margaret, Queen Elizabeth's younger sister, died in her sleep at
6:30 Saturday morning at King Edward VII Hospital in London. CNN
Correspondent Richard Quest reports on the reaction to the princess'
death.</p><p>RICHARD QUEST: Good evening from London, where it is now
Saturday evening, and the weather very much in mood with the nation. It
suddenly started to pour with rain here in the British capital.</p><p>And
all day, people have been hearing and coming to terms with the death of
Princess Margaret, Queen Elizabeth's sister, the youngest daughter of Queen
Elizabeth, the Queen Mother.</p>";
myNewsArray[1] = "<strong>ReplayTV, a viewer's dream</strong><br>By
FRANK BAJAK<br><p>NEW YORK (AP) -- If television network executives are
steamed enough to sue, there must be something exquisitely subversive about
the latest in digital video recorders.</p><p>ABC, CBS and NBC want the
ReplayTV 4000 off the market and have taken its parent company SONICblue to
court, contending that this slim silver box violates their copyrights by
letting users share shows over the Internet.</p><p>But the angst in network
executive suites is really more about something else: These devices allow
viewers to watch what they want when they want -- and automatically bypass
commercials.</p>";
function displayNews() {
// YOUR CODE WHICH DISPLAYS A NEWS
myNewsIndex++;
if (myNewsIndex>myNewsCounter) {
myNewsIndex=1;
}
myNewsDiv.innerHTML = myNewsArray[myNewsIndex-1];
myNewsTimer = window.setTimeout('displayNews()',
(myNewsArray[myNewsIndex-1].length/15)*1000);
}
</script>
<BODY onload="displayNews()">
<div id="myNewsDiv" style="width: 200; height: 300; overflow: auto; border:
1px solid black;"></div>
Cheers
P.s: Just copy and paste this demo into your own HTML editor,
sorry for the long examples...
Sten Hougaard
EDB Gruppen
Application developer/web-designer
UltimateMSTS@a...
ol.com To: "JavaScript HowTo" <javascript_howto@p...>
cc:
02/09/2002 Subject: [javascript_howto] Waiting/pausing JavaScript?
08:26 PM
Please respond
to "JavaScript
HowTo"
Hi all,
I have written a ticker display of latest news (a new letter is displayed
every 0.1 secs), but the problem is that the timer doesn't pause when it
gets to the end of the news bulletin - it carries straight on to the new
bulletin. Thus, there's no time for the user to read the news!
Can anyone tell me if there is an equivalent "wait" or "pause" timer in
JavaScript. I'm aware of setTimeout(), but I want to halt execution of the
script until the timer has elapsed, and not just one phrase within the ()!
Any help appreciated,
Charles Lyons.
$subst('Email.Unsub').