Hello forums
I have this code:
<div id="mainChat" style="display:none">
<div id="chatWindow"></div>
<script type="text/javascript">
setInterval("loadContent()", 1000 );
</script>
</div>
loadContent() is a function to load an external file inside “chatWindow” div. I want it to run every 1 second.
Question: does the setInterval function runs even if “mainChat” div is hidden?
Thanks
Oh jeez it does! I’ll have to call the interval somewhere else. Thanks scallioXtX
system
4
or you can use javascript to check if the div is hidden or not before calling and assigning the setInterval() to a variable
var timer = setInterval("loadContent()", 1000 );
if the div subsequently becomes hidden/invisible then you can use clearInterval() to stop the setInterval from continuing