sunqiusong 2009-04-16 18:53
浏览 281
已采纳

setTimeout问题(急)

现在要实现这样了一个效果。在点击一个下载按钮时,遮罩整个页面。并在遮罩层上方显示一个加载图,在指定的时间10000ms后遮罩效果和加载图又自动隐藏。(本想做一个进度条与数据库读取同步的。但感觉麻烦,所以就设置了一个定值10000ms),下面是js,引用的thickbox.js,对它做了一点点修改。
疑问:我要实现的这样了一个效果。在firefox下设置断点,调试时能达到我要的要求。但断点一去。点击下载的时候。不再显示遮罩层效果。怀疑是不是setTimeout的用法不当。

var tb_pathToImage = "images/loadingAnimation.gif";
var t;// add sunqs
function tb_init(domChunk){
jQuery(domChunk).click(function(){
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
tb_show(t,a,g);
this.blur();
return false;
});
}
function tb_show(caption, url, imageGroup) {
try {
if (typeof document.body.style.maxHeight === "undefined") {//ie6
jQuery("body","html").css({height: "100%", width: "100%"});
jQuery("html").css("overflow","hidden");
if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
jQuery("body").append("

");
}
}else{//all others
if(document.getElementById("TB_overlay") === null){
jQuery("body").append("
");
}
}

if(tb_detectMacXFF()){
jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
}else{
jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
}
if(caption===null){caption="";}
jQuery("body").append("
");//add loader to the page
jQuery('#TB_load').show();//show loader
t=setTimeout(tb_remove(),100000);//add sunqs 10000ms auto disaplear
} catch(e) {
//nothing here
}
}
function tb_remove() {
jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').remove();});
jQuery("#TB_load").remove();
if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
jQuery("body","html").css({height: "auto", width: "auto"});
jQuery("html").css("overflow","");
}
return false;
}
[b]问题补充:[/b]
浏览图显示效果
  • 写回答

3条回答 默认 最新

  • wanghaolovezlq 2009-04-16 19:27
    关注

    改为t=setTimeout("tb_remove()",10000);//add sunqs 10000ms auto disaplear

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致
  • ¥15 禅道二次开发编辑版本,上传不了发行包