Toon posts:

iFrame: height dynamisch aan lengte inhoud

Pagina: 1
Acties:
  • 125 views sinds 30-01-2008
  • Reageer

Verwijderd

Topicstarter
Hallo jongens,

Ik wil via ee Javascript de hoogte van mijn Iframe laten bepalen door de content die erin geladen word. Ik heb nu dit script:

In index.html waar de iframe dus gescript staat:

code:
1
2
3
<td>
<iframe src="home.html" style="width:450"  frameborder="no" id="content" scrolling="no">
scrol="no"></iframe></td>


In de contentpagina.html:
code:
1
2
3
4
5
6
7
8
9
10
<script language="JavaScript">
function bodyheight() {
x = document.body.scrollHeight
parent.document.all.content.style.height = x     
}
</script>
</head>
<body onLoad="bodyheight();">
</body>
</html>


Als ik dit dus uitvoer krijg ik een blanco content :S

Wie weet hoe en waarom?

Bij voorbaat dank

  • Genoil
  • Registratie: Maart 2000
  • Laatst online: 12-11-2023
probeer es clientHeight ipv scrollHeight

  • crisp
  • Registratie: Februari 2000
  • Laatst online: 00:00

crisp

Devver

Pixelated

rrrrr, document.all
je frame resizen kan ook met window.resizeTo() (ja, ook een iframe)
probeer anders dit eens:
JavaScript:
1
2
3
4
5
6
<script type="text/javascript">
function bodyheight() {
  var x = document.body.scrollHeight;
  parent.getElementById('content').style.height = x + 'px';
}
</script>

Intentionally left blank


  • Guillome
  • Registratie: Januari 2001
  • Niet online

Guillome

test

parent.document. ;)
Net getest, werkt als een kip!

[ Voor 46% gewijzigd door Guillome op 01-06-2003 15:24 ]

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


Verwijderd

Topicstarter
Idd, Thanx

  • crisp
  • Registratie: Februari 2000
  • Laatst online: 00:00

crisp

Devver

Pixelated

XLerator schreef op 01 juni 2003 @ 15:24:
parent.document. ;)
Net getest, werkt als een kip!
|:( stom...

Intentionally left blank

Pagina: 1