I’m trying to make a widget that selects an area in the page using JavaScript but the issue is that when it saves the X/Y and Width/Height, it’s actually only relevant to that screen size, so if we try to draw that selection on another user’s computer, it’ll go off the correct position.
On what to rely and how to keep track of an x and y position no matter what the user’s screen size is?
obj.offsetLeftandobj.offsetTopwill always be relative to the top/left corner which is 0,0.window.innerWidth / 2;window.innerHeight / 2;elementNode.offsetWidth;elementNode.offsetHeight;Position the object in the middle of the screen:
Working demo: http://jsfiddle.net/4aenr/