Seite 1 von 1

Dynamisches IFrame funktioniert nur in einem Block

Verfasst: 22.09.2009 23:21
von Ypselon
Ich habe folgendes Problem .. und zwar bastel ich an einem TS Mod fürs Board 3, der es gestattet 2 komplett unabhängige Teamspeak Server darzustellen.
Dazu bediene ich mich 2'er Portalboxen, beide haben jeweils einen eigenen ACP Block.
Weil so ein TS Server ja mal mehr oder weniger voll ist, wollte ich beide Blöcke eine dynamische Höhe geben. Dieses klappt auch einwandfrei, solange ich nur einen Block verwende. Schalte ich den 2.ten Block dazu, wird nur einer dynamisch angezeigt, der 2.te Block aber behält die Höhe die im ACP eingestellt ist.

Hier ist die Routine die ich für die dynamische Höhe verwende :

TS1.HTML

Code: Alles auswählen

<!-- Teamspeak Dyn iFrame -->
<script type="text/javascript">
//ID of Daily Iframe tag:
var iframeids=["TS1"]
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=getFFVersion>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
function dyniframesize() {
var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById){ //begin resizing iframe procedure
			dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);
			if (dyniframe[i] && !window.opera){
				dyniframe[i].style.display="block"
				if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //ns6 syntax
					dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+FFextraHeight + 15;
				else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax
					dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
			}
		}
	}
}
</script>
<!-- end Teamspeak Dyn iFrame -->
{$LR_BLOCK_H_L}<img src="{T_THEME_PATH}/images/portal/ts.png" width="16px" height="16px" alt=""/>&nbsp;{PORTAL_TEAMSPEAK1_NAME}{$LR_BLOCK_H_R}
<!-- IF not S_TEAMSPEAK1_GUEST and not S_USER_LOGGED_IN -->
{L_TEAMSPEAK_NO_USER}
<!-- ELSE -->
<!-- IF S_TEAMSPEAK1_DYNAMIC -->
<iframe align="CENTER" src="portal/teamspeak1/TS_Viewer.php" width="100%" height="{PORTAL_TEAMSPEAK1_HEIGHT_VALUE}" frameborder="0" SCROLLING=NO  name="TS1" id="TS1" onLoad="dyniframesize()"></iframe>
<!-- ELSE -->
<iframe align="CENTER" src="portal/teamspeak1/TS_Viewer.php" width="100%" height="{PORTAL_TEAMSPEAK1_HEIGHT_VALUE}" frameborder="0" ></iframe>
<!-- ENDIF -->
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
Und hier der Code für den zweiten Block :

Code: Alles auswählen

<!-- Teamspeak Dyn iFrame -->
<script type="text/javascript">
//ID of Daily Iframe tag:
var iframeids=["TS2"]
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=getFFVersion>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
function dyniframesize() {
var dyniframe=new Array()
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById){ //begin resizing iframe procedure
			dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);
			if (dyniframe[i] && !window.opera){
				dyniframe[i].style.display="block"
				if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //ns6 syntax
					dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+FFextraHeight + 15;
				else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax
					dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;
			}
		}
	}
}
</script>
<!-- end Teamspeak Dyn iFrame -->
{$LR_BLOCK_H_L}<img src="{T_THEME_PATH}/images/portal/ts.png" width="16px" height="16px" alt=""/>&nbsp;{PORTAL_TEAMSPEAK2_NAME}{$LR_BLOCK_H_R}
<!-- IF not S_TEAMSPEAK2_GUEST and not S_USER_LOGGED_IN -->
{L_TEAMSPEAK_NO_USER}
<!-- ELSE -->
<!-- IF S_TEAMSPEAK2_DYNAMIC -->
<iframe align="CENTER" src="portal/teamspeak2/TS_Viewer.php" width="100%" height="{PORTAL_TEAMSPEAK2_HEIGHT_VALUE}" frameborder="0" SCROLLING=NO  name="TS2" id="TS2" onLoad="dyniframesize()"></iframe>
<!-- ELSE -->
<iframe align="CENTER" src="portal/teamspeak2/TS_Viewer.php" width="100%" height="{PORTAL_TEAMSPEAK2_HEIGHT_VALUE}" frameborder="0" ></iframe>
<!-- ENDIF -->
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
Die Funktion für die dynamische Höhe selbst ist einwandfrei, schalte ich einen Block ab passt sich der andere dynamisch an. Sobald ich aber den zweiten Block zuschalte, wird nur einen angepasst. Woran kann das liegen ?

Re: Dynamisches IFrame funktioniert nur in einem Block

Verfasst: 23.09.2009 00:04
von Mahony
Hallo
Die beiden Funktionen müssen unterschiedliche Namen haben, da sie sonst einander überschreiben.

Grüße: Mahony