Emerson Emerson - 1 year ago 111
Javascript Question

How to get the correct event.pageX from ondragend

Try this code snippet:

window.ondragend = function(event){
window.onmouseup = function(event){

click on a location on a page and then drag an element to the same location. In a maximised window both (at least in Chrome on Windows) pageX' will be the same.
If you minimize the window to fill, say, the right half of the screen, the ondragend will report a different pageX value.

  1. Why does this behaviour happen?

  2. How do I get the correct pageX value from ondragend? Ondragend does not send a mouseup simultaneously, so I can't use that.

Answer Source

This behaviour has been fixed in the latest versions of Chrome.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download