var flag = 0/1 (default=1)
- I want this flag to checked every 30sec over and over until the flag becomes 0 (by an external event that I cant control).
- When the flag is 0 the 30sec-check should end until the flag is 1 again
- As long as the flag is 0 some text should blink on the screen, if the flag goes back to 1 the blinking should stop and the 30sec check should continue.
I tried to do this with setTimeout/setInterval but Im having problem combining them with loops.
Here is some code doing the blinking from another site:
<html>
<head>
<script type="text/javascript">
function init() {
window.setInterval(blink,1000);
}
function blink() {
var elm = document.getElementById('blinkDiv');
if (elm.style.color == "#ff0000")
elm.style.color = "#ffffff";
else
elm.style.color = "#ff0000";
}
</script>
</head>
<body onload="init();" style="background-color: #ffffff;">
<div id="blinkDiv" style="color: #ff0000;">some text</div>
</body>
</html>