Reputation: 633
if i do have a call on an imagebutton like this:
onclick="window.open('link','width=615,resizable,scrollbars').focus(); return false;
how i can open this just right besides the action Button? or how how to get Mouse Cursor Position onclick?
events are not working here onclick="window.open('link','width=615,resizable,scrollbars,left=e.pageX').focus();
also not working here onclick="window.open('link','width=615,resizable,scrollbars').moveTo(e.pageX,0);
Upvotes: 3
Views: 5160
Reputation: 755
you can use the elements:
event.pageX and event.pageY to get the coordinate relative to the document
you can see more details here: mozilla.org - pageX
obs: the "e" on your code stands for "event", try to change it to event and if your trying to insert the left/top value by css you need to add a +'px' to concatenate, because event.page returns only the number.
Upvotes: 1
Reputation: 176
Check this link to get mouse position onMouseMove get mouse position
You can attach a function to the onclick event, and in the function you can call window.moveTo(x, y) to move the window to the position you need
function openWindow() {
var win = window.open(...);
win.moveTo(x, y);
}
Upvotes: 0