Javascript jQuery鼠标不工作
这是我的剧本:Javascript jQuery鼠标不工作,javascript,jquery,html,internet-explorer,mouseleave,Javascript,Jquery,Html,Internet Explorer,Mouseleave,这是我的剧本: $(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 heigh
$(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”。一旦我删除了那个引用,一切都正常了
有人能告诉我为什么会这样吗?当开发人员工具打开时,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.
}
凯文,我很感谢你的编辑,但这就是答案<代码>控制台。日志是IE中的问题。