I'm trying to position a dialog at my mouse position in firefox.
I have one image control. On mouseover of image I call captureMouse() to get mouse position and after click on image I need to show the dialog with its topleft
corner exactly from my mousepointer (On image)
I did following work around
It goes well with IE
but has problems with firefox
Expand|Select|Wrap|Line Numbers
- if(window.Event && document.captureEvents)
- document.captureEvents(Event.MOUSEMOVE);
- document.onmousemove = captureMouse;
- var calX;
- var calY;
- function captureMouse(evt)
- {
- if (!evt)
- var evt = window.event||window.Event;
- if('undefined'!=typeof evt.pageX)
- {
- calX = evt.pageX;
- calY = evt.pageY;
- }
- else
- {
- calX = evt.clientX + document.body.scrollLeft;
- calY = evt.clientY + document.body.scrollTop;
- }
- }
- function goToCalendar(ctl1, ctl2, compareWithDate)
- {
- ///
- /// Some other code
- ///
- if(window.showModalDialog) // IE
- {
- calX = window.screenLeft + calX;
- calY = window.screenTop + calY;
- settings = 'dialogTop=' + calY + 'px;dialogLeft=' + calX +
- 'px;help=no;center=no;dialogWidth=208px;dialogHeight=214px;status=no;resizable=no;scroll=no';
- retValue = window.showModalDialog('Calendar/Calendar.aspx?value=' + secondValue, window, settings);
- }
- else // Firefox
- {
- calX = window.screenX + calX;
- calY = window.screenY + calY;
- retval = window.open('Calendar/Calendar.aspx?value=' + secondValue, 'Choose Date', 'dialog=yes, left=' + calX + ',top=' + calY + ', minimisable=no,
- resizable=no,scrollbars=no,status=no,width=214,height=201,dependent,modal=yes');
- }
- }
In firefox the dialog is placed little bit above the control which is certainly not acceptable by my client
Thanks you guys
Jayvardhan Patil