Status Message Rotator
Keep your UI dynamic. This script loops through an array of text strings and displays them one by one with a time delay.
Tip of the Moment:
Loading...
Copy the Script
<script>
var messages = [
"Welcome to our site!",
"Check out our new features.",
"Don't forget to subscribe!",
"Contact us for support."
];
var i = 0;
function rotate() {
document.getElementById("msgBox").innerText = messages[i];
i++;
if (i >= messages.length) i = 0; // Reset loop
}
setInterval(rotate, 3000); // Change every 3 seconds
</script>
Frequently Asked Questions
Simply add more strings to the `messages` array in the JavaScript code (e.g., `messages[3] = 'New Text'`).
Yes. Instead of incrementing `index++`, you can use `Math.floor(Math.random() * messages.length)` to pick a random message each time.
No, it loops infinitely. If you want it to stop after one cycle, add a check like `if (index >= messages.length) clearInterval(timer)`.