您的位置主页 > 前端技术 > Javascript&js > Thickbox3.1弹出层关闭再打开,文本框不能输入,即无法聚焦

Thickbox3.1弹出层关闭再打开,文本框不能输入,即无法聚焦

2009-12-21    文章来源:互联网    浏览次数:2223     分享文章

  症状:关闭弹出层后,原来页面上的文本框无法聚焦,即文本框变成readyonly(只读)了

  原因和解决方法:这个的原因不好说,很多人都认为是ie本身的bug。是由于iframe没有移除,即使移除了。内存上也么有清除造成的。这也是我猜的。哈哈。解决方法是在tb_remove()中先手动移除iframe然后,在强制做垃圾回收,至少我是可以啦。哈哈。代码如下:

 
  1. function tb_remove() {
  2.     $("#TB_imageOff").unbind("click");
  3.     $("#TB_closeWindowButton").unbind("click");
  4.     $("#TB_window").fadeOut("fast",function(){
  5.         if(navigator.userAgent.indexOf("MSIE")>0) { //如果是IE
  6.             //手动移除iframe,IE的一个bug
  7.             $('#TB_iframeContent').remove();
  8.         }
  9.         $('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();
  10.         if(navigator.userAgent.indexOf("MSIE")>0) { //如果是IE
  11.             //自己调用垃圾回收,强制清楚iframe内存,解决文本框无法输入问题。
  12.             CollectGarbage();
  13.         }
  14.     });
  15.     $("#TB_load").remove();
  16.     if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
  17.         $("body","html").css({
  18.             height: "auto",
  19.             width: "auto"
  20.         });
  21.         $("html").css("overflow","");
  22.     }
  23.     document.onkeydown = "";
  24.     document.onkeyup = "";
  25.     return false;
  26. }

 

文章评论(查看全部)

昵 称 *
电子邮箱 *
网 址      1 + 2 = ?