dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: IE7 zoom vs cursor position

  1. #1
    Join Date
    Oct 2008
    Posts
    349

    IE7 zoom vs cursor position

    Those who worked with cursor positioning probably know that IE doesn't support PageX/Y properties for cursor events. (i.e. the position of the cursor relative to the page) Common solution is to calculate them from (scrollTop + clientY).

    Problem I encountered today is that if the zoom setting in IE7 is not 100%, (scrollTop + clientY) calculation is totally off.

    Anyone know how to fix this?

    Here's some code for anyone wish to test it. As you can see clientX/Y values are relative to the view area, not the page content.
    HTML Code:
    <html>
    <head>
    <script type="text/javascript">
    function analyzeEvent(evt)
    {
    	if (!evt) var evt = window.event;
    	var s = evt.clientX + ' ' + evt.clientY;
    	document.getElementById('output').innerHTML = s;
    }
    
    window.onload = function ()
    {
    	document.body.onmousemove = analyzeEvent;
    }
    </script>
    </head>
    <body>
    <p id='output'></p>
    </body>
    </html>
    Last edited by voidvector; 11-19-2008 at 07:05 PM. Reason: add code sample

  2. #2
    Join Date
    Oct 2008
    Posts
    349
    bump

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles