Foros del Web » Programando para Internet » Javascript »

redimensionar iframe al tamaño del DIV padre

Estas en el tema de redimensionar iframe al tamaño del DIV padre en el foro de Javascript en Foros del Web. Que tal, tengo una duda y consulta: Como puedo redimensionar un iframe al tamaño del div padre que lo contiene? Encontré este código que sirve ...
  #1 (permalink)  
Antiguo 26/07/2009, 21:16
 
Fecha de Ingreso: julio-2009
Mensajes: 19
Antigüedad: 14 años, 9 meses
Puntos: 0
redimensionar iframe al tamaño del DIV padre

Que tal, tengo una duda y consulta:

Como puedo redimensionar un iframe al tamaño del div padre que lo contiene?
Encontré este código que sirve para redimensionar segun el tamaño de la ventana

Código:
<script language="JavaScript">
<!--
function resize_iframe()
{

	var height=window.innerWidth;//Firefox
	if (document.body.clientHeight)
	{
		height=document.body.clientHeight;//IE
	}
	//resize the iframe according to the size of the
	//window (all these should be on the same line)
	document.getElementById("glu").style.height=parseInt(height-
	document.getElementById("glu").offsetTop-8)+"px";
}

// this will resize the iframe every
// time you change the size of the window.
window.onresize=resize_iframe; 

//Instead of using this you can use: 
//	<BODY onresize="resize_iframe()">


//-->
</script>
Y en el iframe:
Código:
<iframe id="glu" width="100%" onload="resize_iframe()"></iframe>
efectivamente lo hace, acá el ejemplo
Cita:
guymal.com/mycode/100_iframe_example.shtml
pero yo necesito que se redimensione al tamaño del DIV padre. Cómo debo armarlo???

Gracias y saludos!
  #2 (permalink)  
Antiguo 27/07/2009, 18:25
Avatar de deirdre  
Fecha de Ingreso: mayo-2009
Mensajes: 690
Antigüedad: 14 años, 11 meses
Puntos: 45
Respuesta: redimensionar iframe al tamaño del DIV padre

Hola jonee

Este es tu código:

Código HTML:
<BODY>
<br>
Notice how the iframe gets its size according to the window size.<Br>
When you resize the window the iframe will resize too.<br><br>

<span id=info>
<!-- This is just for displaying some information -->
</span>
<br>
<br>
<br>
<br>
<iframe id='glu' width=100% onload='resize_iframe()'></iframe>

<div align='right'>&copy; 2003 Guy Malachi - guymal.com, All Rights Reserved</div>
</BODY> 
No tienes el iframe dentro de ningún div.

Te puedes explicar un poco mejor.

Bye
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:06.