Viktor
Viktor

Reputation: 633

How to open PopUp right beside the event Button - how to get Mouse Cursor Position onclick?

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

Answers (3)

Toping
Toping

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

sinduja ramaraj
sinduja ramaraj

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

Freddie Fabregas
Freddie Fabregas

Reputation: 1203

How about looking here for mouse position

Upvotes: 0

Related Questions