JavaScript异步调用定时方法并停止该方法实现代码

时间:2012-03-16    点击:55   
复制代码 代码如下:

(function() {
var t = window.setInterval(function() {
$('#ajaxGame').load('RefreshCurrentPlayerServlet #ajaxGame', function() {
youWin();
youlose();
});
}, 10000);

function youWin() {
if ($('#status:contains("YOU ARE THE WINNER!")').length) {
alert("YOU ARE THE WINNER!");
clearInterval(t);
}
}

function youlose() {
if ($('#status:contains("You lost!")').length) {
alert("You lost!");
clearInterval(t);
}
}
});
javascript 常用功能总结
文本框获得焦点和失去焦点的判断代码
jQuery控制图片的hover效果(smartRollover.js)
基于jQuery的弹出框插件
js性能优化 如何更快速加载你的JavaScript页面
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved