0

EDIT: Solved

My problem is that I need to find a way to constantly read x,y coordinates of the cursor in my browser onmousedown and then to quit reading the x,y coordinates onmouseup here is what I have so far:


var mouseDown = 0;
var xPos = 0;
var yPos = 0;

document.body.onmousedown = function() { 
  mouseDown = 1;
}
document.body.onmouseup = function() {
  mouseDown = 0;
}
function resize(width, height){
    document.getElementById('component1').width=width;
    document.getElementBYId('component1').height=height;
}
function setSize(){
    while(mouseDown == 1)
    {
        xPos = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        yPos = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? 
document.documentElement.scrollTop : document.body.scrollTop);
        resize(xPos, yPos);
    }
    
}

Any suggestions?

1 Answer 1

1

Have a look at http://javascript.internet.com/page-details/mouse-coordinates.html for a working example

Sign up to request clarification or add additional context in comments.

3 Comments

I can't get this to work when mousedown event occurs. How would you do it?
@Matt is this the same page javascriptsource.com/page-details/mouse-coordinates.html as your link is now dead?
@DaveAnderson yeah that's got pretty much the same thing going on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.