locked
How to put a DIV on the center of the window RRS feed

  • Question

  •   var textdiv = document.createElement("DIV");  
      textdiv.style.position = "absolute";  
      textdiv.style.width = "300px";  
      textdiv.style.height = "100px";  
      textdiv.style.left = "200px";  
      textdiv.style.top = "200px";  
      document.body.appendChild(textdiv); 

    I would like to put the div I create dynamically on the center on the screen, therefore replacing "200px" values with something else.
    The point is, however, that the document is larger than the actual browser window. I need to have this DIV visible even if the user has scrolled somewhere.
    Needless to say, this should also work in other browsers than IE :)
    Thanks.
    Tuesday, November 11, 2008 11:04 AM

Answers

All replies