Ver Mensaje Individual
  #6 (permalink)  
Antiguo 03/07/2014, 17:05
Avatar de fedefrankk
fedefrankk
 
Fecha de Ingreso: agosto-2007
Mensajes: 871
Antigüedad: 16 años, 8 meses
Puntos: 7
Pregunta Respuesta: Ventana que se abre

Buenas a todos como andan?... copie tal cual los codigos que pusieron de ejemplo y no me funcinoa....... no se que estoy haciendo mal..
Si me dicen donde esta el famoso error.!!! se los agradecere...

dejo mi archivo

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Documento sin título</title>
  5. <script type="text/javascript">
  6. var mostrar = document.getElementById("mostrar"),
  7.     fondo = document.getElementById("fondo"),
  8.     contenido = document.getElementById("contenido"),
  9.     body = document.body,
  10.     width = window.innerWidth,
  11.     height = window.innerHeight;
  12.  
  13. mostrar.addEventListener("click", function(){
  14.     fondo.style.display = "block";
  15.     fondo.style.width = width + "px";
  16.     fondo.style.height = height + "px";
  17.    
  18.     contenido.style.display = "block";
  19.     contenido.style.top = ((height / 2) - (contenido.offsetHeight / 2) + window.scrollY) + "px";
  20.     contenido.style.left = ((width / 2) - (contenido.offsetWidth / 2) + window.scrollX) + "px";
  21.    
  22.     body.style.overflow = "none";    
  23. }, false);
  24.  
  25. fondo.addEventListener("click", function(){
  26.     fondo.style.display = "none";
  27.     fondo.style.width = 0;
  28.     fondo.style.height = 0;
  29.    
  30.     contenido.style.display = "none";
  31.    
  32.     body.style.overflow = "auto";
  33. }, false);
  34.  
  35. body{
  36.     margin: 0;
  37. }
  38.  
  39. #fondo, #contenido{
  40.     display: none;
  41.     position: absolute;
  42.     z-index: 1000;
  43. }
  44.  
  45. #fondo{
  46.     background: rgba(0, 0, 0, .75);
  47.     top: 0;
  48.     left: 0;
  49. }
  50.  
  51. #contenido{
  52.     background: white;
  53.     width: 25em;
  54.     height: 15em;
  55.     border-radius: .5em;
  56.     overflow: auto;
  57.     /* OPCIONAL */
  58.     text-align: center;
  59.     line-height: 15em;
  60.     font-weight: bolder;
  61. }
  62. </head>
  63.  
  64.  
  65.  
  66. <div id = "fondo"></div>
  67. <div id = "contenido">
  68.     ¡Hola mundo!
  69.     Dale clic al fondo oscuro para cerrar esto
  70. </div>
  71. <button id="mostrar">Mostrar ventana modal</button>
  72. </body>
  73. </html>