2017-03-09 1 views
0

Ich muss die Höhe des Iframe entsprechend dem Inhalt einstellen.Wie setze ich die Iframe-Höhe nach dem Inhalt?

<iframe src="../graphs/Average.html" alt="##graphname" width=100% height=680px overflow:visible frameborder=0 class="general" style="border-collapse: collapse;" noresize onload="document.getElementById('p').style.display='none';"></iframe> 

Ich habe auch versucht: <style> div{overflow:visible} </style> Aber es ist auch nicht funktioniert.

+0

bereits hier beantwortet: http: // Stackoverflow. com/fragen/819416/adjust-width -height-of-iframe-to-fit-with-content-in-it –

+3

Mögliches Duplikat von [Adjust width height von iframe an den Inhalt anzupassen] (http://stackoverflow.com/questions/819416/adjust- width-height-of-iframe-to-fit-with-content-in-it) –

+1

Mögliches Duplikat von [make iframe height dynamic basierend auf Inhalt innerhalb von JQUERY/Javascript] (http://stackoverflow.com/questions/9162933/make-iframe-height-dynamic-based-on-content-inside-jquery-javascript) –

Antwort

0

Dazu geben Sie folgende JScode verwenden:

<iframe id="iframe" src="../graphs/Average.html" alt="#graphname" width="100%" height="680" frameborder=0 class="general" style="border-collapse: collapse;" noresize onload="document.getElementById('p').style.display='none';"></iframe>  

Mit Javascript

document.getElementById("iframe").style.height = $('#iframe').get(0).contentWindow.document.body.offsetHeight + 'px' 

Mit jQuery

$('#iframe').height($('#iframe').get(0).contentWindow.document.body.offsetHeight + 'px'); 
+0

Mit diesem auch overflow: visible funktioniert nicht. Bildlaufleiste kommt, ich brauche die Daten in voller Länge der Seite nicht in Bildlauf. –

Verwandte Themen