Answer Question
how to center a div on the screen?
I need to center a div on the screen (through javascript), but I'm having trouble doing so.
This is my code:
var objLeft = (document.body.clientWidth - pleaseWaitBox.offsetWidth) / 2;
var objTop = (document.body.clientHeight - pleaseWaitBox.offsetHeight) / 2;
objLeft = objLeft + document.body.scrollLeft;
objTop = objTop + document.body.scrollTop;
// Position object
pleaseWaitBox.style.position = "absolute";
pleaseWaitBox.style.top = objTop + "px";
pleaseWaitBox.style.left = objLeft + "px";
Do you know what I'm doing wrong or if there is another better way of doing it?
Thanks,
David
TEXT
Uploading file and scanning for virus...
Please Wait