I wish to create a speed reading software of my own. For that, I need the text to continuously change and stop when the passage gets over. I have tried something where the contents are included in any array and the text continuously changes perfectly but it doesnt stop and continuosly rotates the array contents. I wish to stop the text when the array comes to an end. PLease help me !!!!
And here is my code,
<html>
<head>
<title>Replacing Text</title>
<script language="JavaScript">
var msgIX = 0
var msgs = new Array(
"Notice anything different?",
"The text you are looking at has changed.",
"This is a handy way of sending messages to your users."
)
function scrollMessages(milliseconds) {
window.setInterval("displayMessage()", milliseconds)
}
function displayMessage() {
if(document.getElementById != null) {
var heading = document.getElementById("scrollme")
heading.firstChild.nodeValue = msgs[msgIX]
}else{
if(navigator.appName == "Microsoft Internet Explorer") {
var heading = document.all.item("scrollme")
heading.innerText = msgs[msgIX]
}
}
++msgIX
msgIX %= msgs.length
}
</script>
</head>
<body onload="scrollMessages(2000)">
<h1 align="center" id="scrollme">Watch this text very carefully!</h1>
</body>
</html>
Try this
<html>
<head>
<title>Replacing Text</title>
<script language="JavaScript">
var msgIX = 0
var msgs = new Array(
"Notice anything different?",
"The text you are looking at has changed.",
"This is a handy way of sending messages to your users."
)
function displayMessage(milliseconds) {
if(msgIX < msgs.length){
if(document.getElementById != null) {
var heading = document.getElementById("scrollme")
heading.firstChild.nodeValue = msgs[msgIX]
}else{
if(navigator.appName == "Microsoft Internet Explorer") {
var heading = document.all.item("scrollme")
heading.innerText = msgs[msgIX]
}
}
++msgIX;
window.setTimeout(function(){displayMessage(milliseconds);},milliseconds);
}
}
</script>
</head>
<body onload=" window.setTimeout(function(){displayMessage(5000);},5000);">
<h1 align="center" id="scrollme">Watch this text very carefully!</h1>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With