最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Did windows update 2846071 break the handling of window.event.clientX clientY? - Stack Overflow

programmeradmin1浏览0评论

Did windows update /?kbid=2846071 break the handling of window.event.clientX and clientY? It seems that Windows 7 machines using IE 9 or 10 now return something that looks like the window position (top left corner) rather than the mouse position within the window. The numbers look accurate, but may be negative.

Or is that a "fix" and I should really be using something else for the mouse position.

I was using it in window.onbeforeunload to detect a user leaving the page without logging out and giving them the boot, but I'm disabling that today until I figure this out.

Did windows update http://support.microsoft./?kbid=2846071 break the handling of window.event.clientX and clientY? It seems that Windows 7 machines using IE 9 or 10 now return something that looks like the window position (top left corner) rather than the mouse position within the window. The numbers look accurate, but may be negative.

Or is that a "fix" and I should really be using something else for the mouse position.

I was using it in window.onbeforeunload to detect a user leaving the page without logging out and giving them the boot, but I'm disabling that today until I figure this out.

Share Improve this question edited Apr 24, 2022 at 16:01 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Jul 11, 2013 at 21:57 derekderek 433 bronze badges 2
  • @Teemu Your reference has "Build date 6/14/2013", while the derek's source is dated July 9, 2013. – Rob W Commented Jul 11, 2013 at 22:42
  • Is there a workaround for this? – Guanxi Commented Jul 30, 2013 at 17:47
Add a ment  | 

4 Answers 4

Reset to default 3

This link: http://social.technet.microsoft./Forums/windows/ja-JP/0985853c-0376-48d0-b748-c4259c0fc4a9/26356260321250312525124641252112512-kb2846071 implies that this was an intentional oute.

It may be that this was changed to address the security concern here: http://blogs.msdn./b/ie/archive/2012/12/13/update-to-alleged-information-and-security-issue-with-mouse-position-behavior.aspx

Argh! Ok so here is the issue Microsoft was trying to fix AND what they broke in the process.

Originally IE was leaking the event coordinates outside the browser viewport (1) (e.g. in a region that the webpage should not know about) as well as leaking the coordinates when the IE window didn't have the active focus (2) (e.g. when you are in another app, or on another monitor... and finally it leaked some keystrokes (3).

It looks like Microsoft fixed the leaking of coordinates... but did so by COMPLETELY removing all of them... including the USEFUL in viewport coordinates!

e.g. events are returning undefined for X,Y coordinates that are most certainly 100% inside the browser viewport.

This really looks like something Microsoft didn't intend releasing.

  • Previously, they have stated they did not think there was any risk "outside the lab"
  • The change is undocumented in the patch, which refers to "Memory Corruption" and "JIS Character Encoding Vulnerabilities"
  • If clientX only returned coordinates within the page, the risk goes away

Is a patch for the patch on the way?

Further: The problem with clientX/clientY (and similar properties) is dependent on the event used to fire the javascript. I've found that onfocus returns incorrect coordinates, but onclick returns correct coordinates. Haven't tried other events.

The javascript in the OP was broken by this Microsoft July 2013 update (this is even acknowledged in the "Known issues" section):

http://support.microsoft./kb/2846071/en-gb

But it was fixed in this August 2013 update:

http://support.microsoft./kb/2862772

I have confirmed that clients on which I install the Aug update no longer have the issue.

发布评论

评论列表(0)

  1. 暂无评论