弹出alert对话框致使setInterval()不执行

我的页面中使用js实现一个秒表功能,但是当我的页面弹出对话框时,秒表停止不走了,这个怎么解决啊?请各位大侠帮忙解决。谢谢

繁花不似锦
浏览 750回答 2
2回答

开心每一天1111

不要在同一个函数中实现表秒功能和弹出对话框。

慕无忌1623718

1 <head> 2 &nbsp;<script type="text/javascript"> 3 function getdate() 4 { 5 &nbsp;&nbsp;var day=new Date(); 6 &nbsp;&nbsp;document.getElementById("daydate").innerHTML=day.getFullYear()+"年"+((day.getMonth()+1)>9?(day.getMonth()+1):"0"+ 7 &nbsp;&nbsp;(day.getMonth()+1))+"月"+(day.getDate()>9?day.getDate():"0"+day.getDate())+"日"+(day.getHours()>9?day.getHours():"0"+ 8 &nbsp;&nbsp;day.getHours())+":"+(day.getMinutes()>9?day.getMinutes():"0"+day.getMinutes())+":"+(day.getSeconds()>9?day.getSeconds():"0"+ day.getSeconds()); 9 }10 window.setInterval("getdate()",1000);11 &nbsp;&nbsp; &nbsp;</script>12 13 </head>14 <body>15 &nbsp;&nbsp; &nbsp;<form id="form1" runat="server">16 &nbsp;&nbsp; &nbsp;<div>17 &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<asp:Label runat="server" ID="daydate" Text=""></asp:Label>18 &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<input type="button" onclick="alert('123');" value="123" />
打开App,查看更多内容
随时随地看视频慕课网APP