Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/01/2009, 21:44
Avatar de omar190
omar190
 
Fecha de Ingreso: septiembre-2008
Mensajes: 191
Antigüedad: 15 años, 7 meses
Puntos: 4
Respuesta: Alargar iframe

Si lo que quieres es redimensionar un iframe al cargar una seccion. Yo utilizo el siguiente codigo no recuerdo si lo encontre en el foro de javascript pero me fue muy util:

Código javascript:
Ver original
  1. <script type="text/javascript">
  2. <!--
  3. function getWindowData(n,i){
  4.     var ifr=document.getElementById(i).contentWindow.document || document.getElementById(i).contentDocument;
  5.     var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
  6.     if (typeof window.frames[n].innerWidth != 'undefined'){
  7.         widthViewport= window.frames[n].innerWidth;
  8.         heightViewport= window.frames[n].innerHeight;
  9.     }else if(typeof ifr.documentElement != 'undefined' && typeof ifr.documentElement.clientWidth !='undefined' && ifr.documentElement.clientWidth != 0){
  10.         widthViewport=ifr.documentElement.clientWidth;
  11.         heightViewport=ifr.documentElement.clientHeight;
  12.     }else{
  13.         widthViewport= ifr.getElementsByTagName('body')[0].clientWidth;
  14.         heightViewport=ifr.getElementsByTagName('body')[0].clientHeight;
  15.     }
  16.     xScroll=window.frames[n].pageXOffset || (ifr.documentElement.scrollLeft+ifr.body.scrollLeft);
  17.     yScroll=window.frames[n].pageYOffset || (ifr.documentElement.scrollTop+ifr.body.scrollTop);
  18.     widthTotal=Math.max(ifr.documentElement.scrollWidth,ifr.body.scrollWidth,widthViewport);
  19.     heightTotal=Math.max(ifr.documentElement.scrollHeight,ifr.body.scrollHeight,heightViewport);
  20.     return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
  21. }
  22. function resizeIframe(ID,NOMBRE){
  23. document.getElementById(ID).height=null;
  24. document.getElementById(ID).width=null;
  25. window.location='#';//necesario para safari
  26. var m=getWindowData(NOMBRE,ID);
  27. document.getElementById(ID).height=m[5];
  28. document.getElementById(ID).width=m[4]+22;
  29. }
  30. function addEvent(obj, evType, fn, useCapture){
  31.  
  32.  if (obj.addEventListener){
  33.     obj.addEventListener(evType, fn, useCapture);
  34.    
  35.   } else if (obj.attachEvent){
  36.     obj.attachEvent("on"+evType, fn);
  37.    
  38.   } else {
  39.    obj['on'+evType]=fn;
  40.   }
  41. }
  42. window.onload=function(){
  43.     resizeIframe('gral','gral');
  44.     addEvent(document.getElementById('gral'), 'load', function(){resizeIframe('gral','gral');}, false);
  45. }
  46.  
  47. //-->
  48. </script>