Hallo,
ich hatte vorgestern in folgendem Thread
http://forum.de.selfhtml.org/?t=44569&m=243017
die Frage nach einem Workaround zur automatischen Adjustierung von Iframes gestellt. Der Vorschlag von Maxx hat bei mir leider nicht funktioniert, der Code von
http://www.faqts.com/knowledge_base/view.phtml/aid/1076
dagegen in Ansaetzen schon.
Ich zitiere:
<I>"...
The onload handler of the body of the document in the iframe has to
call a function in the parent window which then adjusts the size.
Here is the document containing the iframe:
...
<script type="text/javascript">
function adjustIFrameSize (iframeWindow) {
if (iframeWindow.document.height) {
var iframeElement = parent.document.getElementById
(iframeWindow.name);
iframeElement.style.height = iframeWindow.document.height + 'px';
iframeElement.style.width = iframeWindow.document.width + 'px';
}
else if (document.all) {
var iframeElement = parent.document.all[iframeWindow.name];
if (iframeWindow.document.compatMode &&
iframeWindow.document.compatMode != 'BackCompat')
{
iframeElement.style.height =
iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
iframeElement.style.width =
iframeWindow.document.documentElement.scrollWidth + 5 + 'px';
}
else {
iframeElement.style.height =
iframeWindow.document.body.scrollHeight + 5 + 'px';
iframeElement.style.width =
iframeWindow.document.body.scrollWidth + 5 + 'px';
}
}
}
</script>
Note that the <iframe> tag has both name and id attribute set to the
same value. This is necessary to allow the iframe window object to
find the corresponding <iframe> element.
Here is the example test page (test20020403.html) which creates a page with random length. For your own iframe pages you need to copy the onload handler:
...
<body onload="if (parent.adjustIFrameSize)
parent.adjustIFrameSize(window);"
"</I>
Das funktioniert aber nur wenn die Seiten im gleichen Verzeichnis liegen, wie mir scheint
Beispiel: Die beiden Seiten <A HREF="http://www.uni-mainz.de/~schwt026/blogger/main.html">main.html</A> und <A HREF="http://www.uni-mainz.de/~schwt026/blogger/main_2.html">main_2.html</A> sind absolut identisch bis auf den Speicherort des ebenfalls identischen iframe-Dokuments. Im Falle von main.html ist dies das gleiche Verzeichnis (Dokument "444.html") im Falle von main_2.html ist dies "http://testagain444.blogspot.com".
In letzterem Fall erzeugt der Code keine Wirkung. Wieso????
Danke fuer jeden Strohhalm!
Gruss, Tobias