2012-03-02 52 views
0

因此,这里是我的脚本:jQuery的鼠标离开IE浏览器不工作

$(document).bind('mouseleave', function(event) {   
      // show popup 
      console.log("you are about to leave the form!"); 
      //Get the A tag 
      var id = $("#dialog"); 

      //Get the screen height and width 
      var maskHeight = $(document).height(); 
      var maskWidth = $(window).width(); 

      //Set heigth and width to mask to fill up the whole screen 
      $('#mask').css({'width':maskWidth,'height':maskHeight}); 

      //transition effect  
      $('#mask').fadeIn(250); 
      $('#mask').fadeTo("slow",0.8); 

      //Get the window height and width 
      var winH = $(window).height(); 
      var winW = $(window).width(); 

      //Set the popup window to center 
      $(id).css('top', winH/2-$(id).height()/2); 
      $(id).css('left', winW/2-$(id).width()/2); 

      //transition effect 
      $(id).fadeIn(500); 
    }); 

该代码在所有浏览器,但IE的伟大工程。唯一一次它似乎工作的时候,我已经激活了“开发人员工具”...实际可绑定的“mouseleave”触发器似乎并没有工作。

任何想法?


看来,IE不喜欢在方法中的“console.log”调用。一旦我删除了该参考,所有工作。

有人能告诉我为什么可能吗?

+0

千电子伏,我很欣赏的编辑,但是这就是答案...'console.log'是在IE中的问题。 – dcolumbus 2012-03-02 23:51:36

回答

0

当开发者工具打开时,IE仅支持console.log()。我认为这只是他们做出的一个设计决定。您可以尝试通过定义自己的日志记录功能,克服这个在你的代码:

var log = function(s) { 
    try { 
    console.log(s); 
    } catch (e) { 
    alert(s); // If you want to see annoying popups. 
    }   // If not, just leave this empty. 
} 
相关问题