单击图像时在IE7和IE8中触发window.blur(window.blur triggered in IE7 and IE8 when clicking on an image)

编程入门 行业动态 更新时间:2024-10-24 05:17:43
单击图像时在IE7和IE8中触发window.blur(window.blur triggered in IE7 and IE8 when clicking on an image)

在Internet Explorer 7和8中,但不是9和更新版本,单击包含网站上图像的div会触发window.blur事件。 但这是错误的。

但是,这非常失效,因为我们使用此方法来确定用户是否离开了网站(焦点在另一个窗口)。

有关如何解决此问题的任何想法?

In Internet Explorer 7 and 8, but not in 9 and newer, clicking on a div which contains an image on a website, triggers the window.blur event. But this is wrong.

However, this is very disfunctional, because we use this method to find out if the user leaves the website (focus is on another window).

Any idea on how to workaround this problem?

最满意答案

我通过在window.blur回调中检查document.hasFocus()作为第一件事来解决了这个问题。 如果它被错误地触发,至少文档仍然具有焦点。

问题可能是由于使用HTML 5标签,如article和section混淆旧IE。

I solved the problem by checking document.hasFocus() as a first thing in the window.blur callback. If it gets triggered wrongly, at least the document does still has focus.

The problem was probably due to using HTML 5 tags such as article and section which confused the old IEs.

更多推荐

window,网站,website,blur,div,电脑培训,计算机培训,IT培训"/> <meta name="de

本文发布于:2023-08-07 19:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466000.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   图像   window   triggered   clicking

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!