Center xul dialog on screen
The end result is a window that moves by itself? Please don't make it too annoying :)
In any case, you will need to do it manually using window.moveTo
and various properties screen
(see https://developer.mozilla.org/en/DOM/window )
Here's an interesting example, although it does not center the window, it makes it visible: http://www.koders.com/javascript/fid3F51B87DFD457428278627805CCA8D39ADC13455.aspx?s=window#L3
source to share
I also searched around and looked at the MDC for anything to center it, but couldn't find anything, so I created this! This will work both in the window and in the dialog.
var w=(screen.availWidth/2)-(document.getElementById('windowID').width/2);
var h=(screen.availHeight/2)-(document.getElementById('windowID').height/2);
window.moveTo(w,h);
The only thing you have to change is windowID
to your window id value. It will work on all screen resolutions as it takes the total screen width and height and then divides it in half, thereby giving the center of the screen, and then subtracts your width and height settings to account for them, but halves them and compensates for the window without offset will not be centered.
Hope this helped!
source to share