window.onblur 事件在使用 IE8 时也会触发 window.onfocus 事件
window.onblur event also triggers window.onfocus event when using IE8
这两个事件都在模糊事件时被触发。
<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication1.WebForm1" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="js/jquery-1.7.2.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
window.onfocus = function() {
$('#msg').html($('#msg').html() + '<br/> focus');
};
window.onblur = function() {
$('#msg').html($('#msg').html() + '<br/> Blur');
};
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="msg">
</div>
</asp:Content>
终于解决了。谢谢大家的帮助!
$(window).bind("load", function() {
pageLoad();
});
var activeElement;
function pageLoad() {
activeElement = document.activeElement;
document.onfocusout = logWindow;
}
function logWindow() {
if (activeElement != document.activeElement) {
activeElement = document.activeElement;
}
else {
$('#msg').html($('#msg').html()+'<br/> Focus');
}
}
window.onblur = function() {
$('#msg').html($('#msg').html() + '<br/> Blur');
return false;
};
可能是事件正在冒泡。
相关文章:
- $window.ga在AngularJS事件中未定义
- window.on.scroll事件未启动
- 检测window.opener窗口刷新事件
- 如何在javascript中添加带有回调函数的按钮点击事件作为window.conf
- Window.onblur-禁用iframe事件
- Turbolinks等效于window.load的事件
- 如何在提示下获取和使用从window.onbeforeunload事件的返回语句显示的值
- jQuery $(window).scroll事件处理程序关闭但仍在触发
- 如果我在 window.onbeforeunload 事件上确认是,我如何调用另一个 Java 脚本函数
- 在处理元素单击事件期间,在循环内部调用window.open()
- 为什么调用Window.scroll()会产生一个受信任的事件
- jquery对话框打开事件中的window.resize事件
- 翻译一篇文章'上.单击'PHP中的事件,来自'window.open'到基本URL链接
- JQuery Mobile,通过window.location重定向可阻止页面显示事件
- “;预加载“;<音频>影响window.onload事件时间
- 当我禁用window.onwheel事件时,它会使Firefox中的所有object.onwheele事件也被禁用
- 在Firefox for Android的onload事件中,window.innerWidth的值错误
- onClick事件window.location.href而不是window.PHP中的开放问题
- JavaScript代码说明:(e &&E.target) ||(窗口.事件,,window.event.srcElem
- 使用window.event.keyCode在javascript中捕获f5按键事件window.onbeforeunl