Twango Posted March 7, 2010 Share Posted March 7, 2010 Clear interval not working. why?<script type="text/javascript" language=javascript>function doClaim(){var nc=self.setInterval("alert('go')",1000);stop=setTimeout("nc=window.clearInterval(nc)",1500);}</script><input type="button" style="color:white;background-color:red;font-size:20px;font-weight:bold" value="CLAIM PRIZES!!!" onclick="doClaim()"/> Link to comment Share on other sites More sharing options...
justsomeguy Posted March 8, 2010 Share Posted March 8, 2010 The variable nc is local to the doClaim function, but the code which setTimeout runs gets executed in the global scope. The interval variable needs to be global for that to work. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.