3

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);

Viktor
  • 623
  • 4
  • 10
  • 25

3 Answers3

1

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.

Toping
  • 754
  • 5
  • 16
0

How about looking here for mouse position

Freddie Fabregas
  • 1,162
  • 1
  • 7
  • 17
0

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);
 }
Community
  • 1
  • 1