Posted in

Resize window (popup por ejemplo) con javascript

Se le pasa ancho y alto y hace resize a la ventana (gradual).

function restaurtamany(ancho,alto){
ovar myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
  }
  if(myWidth<ancho){
  for(l=myWidth;l<ancho;l+=5){
  window.resizeTo(l,myHeight);
  }
  }else{
   for(l=myWidth;l>ancho;l-=5){
  window.resizeTo(l,myHeight);
  }
  }
  if(myHeight<alto){
   for(y=myHeight;y<alto;y+=5){
  window.resizeTo(ancho,y);
  }
  }else{
  for(y=myHeight;y>alto;y-=5){
  window.resizeTo(ancho,y);
  }
  }
window.resizeTo(ancho,alto);
}


// Control de la ventana

function tamany(ancho,alto){
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
//var ample:Number=0;
ample=ancho-4;
alt=alto-5;
restaurtamany(ample+4,alt+4);
//alert("Non IE : Ancho y alto: "+ancho+" / "+alto+" Tratado a: "+ample+" / "+alt);
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
//alert("ie6+");
 restaurtamany(ancho+4,alto+4);
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
   restaurtamany(ancho+4,alto+4);
   //alert("ie4");
  }
  
}

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *


The reCAPTCHA verification period has expired. Please reload the page.