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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)