Copy Code code as follows:
<script language= "JavaScript" >
function Pollconn () {
Timecounter=window.settimeout (' Pollconn (); ', 5000);
function Stoppoll () {
Window.cleartimeout (Timecounter)
}
Pollconn ();
</script>
The above method is generally a more general method. Keep calling yourself every 5 seconds. In general, a user accessing a page containing such code does not feel that it has a problem. But if users need to stay on such pages for a long time, they will use the problem. Because settimeout will not stop the "spit" CPU, slowly the CPU will eventually be eaten up by such code, causing IE to die, or stop execution.
The solution, before the next call with the cleartimeout to clear the first.
Copy Code code as follows:
<script language= "JavaScript" >
function Pollconn () {
if (timecounter) window.cleartimeout (timecounter)//Clear Last SetTimeout
Timecounter=window.settimeout (' Pollconn (); ', 5000);
function Stoppoll () {
Window.cleartimeout (Timecounter)
}
Pollconn ();
</script>