function pruefe() {
if(document.all&&!window.opera) {
Das (DOM-Modell von IE 4-5) kannst du im Jahr 2009 weglassen und auf das W3C DOM setzen.
var a=document.all.profil;
profil.document.body.scroll='no';
} else {
var a=document.getElementsByName('profil')[0];
Nutze besser eine ID für das IFrame und dann getElementById.
a.scrolling='no';
}
var a=document.getElementsByName('profil')[0];
Wieso wiederholst du die Abfrage hier.
profil.document.getElementsByTagName('body')[0].style.overflow='hidden';
Auch hier ist getElementsByTagName unnötig, nutze .document.body.
Beziehungweise: Wenn du auf das document-Objekt des Dokuments im Iframe zugreifen willst, geht das nicht in allen Browser mit .document. Sondern eher so http://xkr.us/articles/dom/iframe-document/
var b=profil.document.getElementById('cont');
if(a.style.height != eval(b.offsetHeight+35)+'px') {
a.style.height=eval(b.offsetHeight+35)+'px';
eval ist hier unnötig und macht das ganze unnötig langsamer.
Warum nicht einfach so:
function iframe_höhe_anpassen (id)
var iframe = document.getElementById(id);
iframe.scrolling = "no";
// Browserübergreifend auf das Dokument im Iframe zugreifen
if (iframe.contentDocument) {
var iframe_document = iframe.contentDocument;
} else if (iframe.contentWindow) {
var iframe_document = iframe.contentWindow.document;
} else {
return;
}
iframe_document.body.scroll = "no";
iframe_document.body.style.overflow = "hidden";
// Inwiefern die beiden vorigen nötig sind, weiß ich nicht, aber ich nehme mal an, du weißt es.
iframe.style.height = iframe_document.offsetHeight + 35 + 'px';
}
iframe_höhe_anpassen("iframe-id");
Mathias