automatyczna zmiana rozmiaru iframe, która dynamicznie zmienia wysokość (mniejsza lub większa)
Wiem, że jest wiele postów na temat zmiany rozmiaruiframe
ale wszystko co znalazłem to ten kod:
<script type="text/javascript" language="JavaScript">
<!--
function autoResize(id) {
var newheight;
var newwidth;
if (document.getElementById) {
newheight = document.getElementById(id).contentWindow.document.body.scrollHeight;
newwidth = document.getElementById(id).contentWindow.document.body.scrollWidth;
}
document.getElementById(id).height = (newheight);
document.getElementById(id).width = (newwidth);
};
//-->
</script>
a to jest przykładowy kod znaczników:
<a href="index.php" target="content">Home</a>
<a href="profile.php" target="content">Profile</a>
<iframe src="index.php" name="content" height="500px" width="100%" id="Main_Content" onload="autoResize('Main_Content');"></iframe>
powyższe kody działają, ale mam jeden problem. rozważ ten scenariusz:
index.php page height is 800px
i
profile.php page height is 1200px
kiedy klikam link doindex.php
strona, do której zmienia się iframe800px
, a następnie klikam link doprofile.php
strona iiframe
zmienia rozmiar na1200px
ALE to mój problem, kiedy ponownie klikam link doindex.php
która jest wysokość jest mniejsza niżprofile.php
strona,iframe
nie zmienia rozmiaru i nie dostosowuje800px
wysokość i powoduje nadmiar przestrzeni poniżej zawartościindex.php
co nie wygląda dobrze, nie mam problemu ze wzrostem wysokości iframe, ale mając problemy z jego kurczeniem, każdy może mi pomóc? wszelka pomoc jest doceniana. dzięki!