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 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料