iFrame an größe des Dokuments anpassen?
Christian Ludwig
- dhtml
Hallo,
warum wird die Größe des iFrames nicht automatisch an das Dokument im iFrame angepasst?
Auch ein 'overflow' oder 'overflow-y', wie hier beschrieben http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/overflowY.asp funktioniert nicht.
Netscape 4 mit den Layern macht da keine Probleme.
Am Rande gefragt: Wie sieht der JS Befehl aus um im NS6 eine andere Quelle für den iFrame anzugeben?
document.iframe1.location.href="http://xxx.yy" klappt dort nicht.
hier mein Quelltext des Hauptdokuments:
----------------------------
<html>
<head>
<script language="JavaScript">
<!--
function iFrameSrc(wert) {
if (document.layers)
document.layers[0].src=wert;
else
document.iframe1.location.href=wert;
}
// -->
</script>
</head>
<body>
<iframe src="inhalt1.html" name="iframe1" id="iframe1" target="_parent" frameborder="0" scrolling="no" style="position:absolute; top:150; left:75; z-index:30; visibility: visible; overflow-y: visible"></iframe>
<layer id="Layer1" left="75" top="150" z-index="30" src="inhalt1.html" visibility="show" scrolling="no"></layer>
<p><a href="javascript:iFrameSrc('inhalt1.html');">Text 1</a></p>
<p><a href="javascript:iFrameSrc('inhalt2.html');">Text 2</a></p>
</body>
</html>
----------------------------
Und die Dateie inhalt1.html
----------------------------
<html>
<head>
</head>
<body>
<table width="150" height="50" border="1" >
<tr>
<td bgcolor="#ff0000"><h1>Laber 1</h1></td>
</tr>
</table>
</body>
</html>
----------------------------
und inhalt2.html
----------------------------
<html>
<head>
</head>
<body>
<table width="350" height="310" border="1" >
<tr>
<td bgcolor="#0000ff"><h1>Noch mehr Text Blubber</h1></td>
</tr>
</table>
</body>
</html>
----------------------------
Vielen Dank,
Christian
Hi again,
bin ein Stück weiter:
________________________
<html>
<head>
<script language="JavaScript">
<!--
function iFrameSrc(wert) {
if (document.layers)
document.layers[0].src=wert;
else {
document.iframe1.location.href=wert;
document.all('iframe1').style.height = document.iframe1.document.body.scrollHeight;
}
}
// -->
</script>
</head>
<body>
<iframe src="inhalt1.html" name="iframe1" id="iframe1" target="_parent" frameborder="0" scrolling="no" style="position:absolute; top:150; left:75; width:500; z-index:30; visibility: visible; overflow: auto"></iframe>
<layer id="Layer1" left="75" top="150" z-index="30" src="inhalt1.html" visibility="show" scrolling="no"></layer>
<p><a href="javascript:iFrameSrc('inhalt1.html');">Text 1</a></p>
<p><a href="javascript:iFrameSrc('inhalt2.html');">Text 2</a></p>
</body>
</html>
---------------------
Allerdings liefert das Objekt 'document.iframe1.document.body.scrollHeight' immer den Wert des vorherigen HTML Dokuments zurück.
Such noch ein onload Event, der funktioniert.
Ciao
Und schon wieder,
was ist heute nur hier im Forum los??? So lange habe ich schon lange nicht mehr auf eine Antwort warten müssen.
Die Lösung:
<html>
<head>
<script language="JavaScript">
<!--
function iFrameSrc(wert) {
if (document.layers)
document.layers[0].src=wert;
else
document.iframe1.location.href=wert;
}
function hoehe(){
document.all('iframe1').style.height = document.iframe1.document.body.scrollHeight;
}
// -->
</script>
</head>
<body>
<iframe src="inhalt1.html" name="iframe1" id="iframe1" target="_parent" frameborder="0" scrolling="no" style="position:absolute; top:150; left:75; width:500; z-index:30; visibility: visible; overflow: auto"></iframe>
<layer id="Layer1" left="75" top="150" z-index="30" src="inhalt1.html" visibility="show" scrolling="no"></layer>
<p><a href="javascript:iFrameSrc('inhalt1.html');">Text 1</a></p>
<p><a href="javascript:iFrameSrc('inhalt2.html');">Text 2</a></p>
</body>
</html>
--------------------------
jetzt wird in die Dateien 'inhalt1.html' und 'inhalt2.html'
nur noch folgender body-tag eingebaut:
<body onload="parent.hoehe();">
Das ist alles ;-)
Ciao