By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,035 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,035 IT Pros & Developers. It's quick & easy.

Firefox: Dialog position problem

P: 1
Hi All,

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
  1. if(window.Event && document.captureEvents)
  2.     document.captureEvents(Event.MOUSEMOVE);
  3.  
  4. document.onmousemove = captureMouse;
  5.  
  6. var calX;
  7. var calY;
  8.  
  9. function captureMouse(evt)
  10. {
  11.      if (!evt)
  12.         var evt = window.event||window.Event;
  13.  
  14.     if('undefined'!=typeof evt.pageX)
  15.     {
  16.         calX = evt.pageX;
  17.         calY = evt.pageY;
  18.     }
  19.     else
  20.     {
  21.         calX = evt.clientX + document.body.scrollLeft;
  22.         calY = evt.clientY + document.body.scrollTop;
  23.     }
  24. }
  25.  
  26. function goToCalendar(ctl1, ctl2, compareWithDate)
  27. {
  28. /// 
  29. /// Some other code
  30. ///
  31.  
  32. if(window.showModalDialog) // IE
  33.     calX = window.screenLeft + calX;
  34.     calY = window.screenTop + calY;    
  35.     settings = 'dialogTop=' + calY + 'px;dialogLeft=' + calX + 
  36.  
  37. 'px;help=no;center=no;dialogWidth=208px;dialogHeight=214px;status=no;resizable=no;scroll=no';
  38.               retValue = window.showModalDialog('Calendar/Calendar.aspx?value=' + secondValue, window, settings);
  39. }
  40. else // Firefox
  41.     calX = window.screenX + calX;
  42.     calY = window.screenY + calY;
  43.  
  44.     retval = window.open('Calendar/Calendar.aspx?value=' + secondValue, 'Choose Date', 'dialog=yes, left=' + calX + ',top=' + calY + ', minimisable=no, 
  45.  
  46. resizable=no,scrollbars=no,status=no,width=214,height=201,dependent,modal=yes');
  47. }
  48. }

In firefox the dialog is placed little bit above the control which is certainly not acceptable by my client

Thanks you guys

Jayvardhan Patil
Oct 24 '07 #1
Share this Question
Share on Google+
1 Reply


100+
P: 428
screenY in mozilla returns the distance to the top of the window chrome,
screenTop in IE returns the distance to the top of the window content, below the toolbars.

you can get closer to the screenTop value with:
screenY+(screen.height-screen.availHeight)

screenX has the same behavior, although usually there are no toolbars on the left to offset the content.
Oct 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.