Hi JavaScriptspezialisten,
im nachfolgenden Code gibt jeder der getesteten Browser nach Veränderung der Fensterweite die aktuelle Fensterweite in Pixel automatisch im rosa Textfeld an. Nur der Mozilla-Firefox 1.0 reagiert erst nach reLoad (der Firefox 9.x soll noch korrekt funktionieren). Hat hier im Forum jemand eine Ahnung woran das liegen kann? Warum die Fensterhöhe nach Veränderung derselben nur vom IE korrekt angezeigt wird, würde mich zwar auch interessieren, ist aber nicht sehr wichtig.
Besten Dank für jede Hilfe
Harry
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Firefox</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<style type="text/css">
<!--
body { margin:0px; }
#txt { position:absolute;
top:15%;
left:15%;
width:70%;
font-size:100%;
color:#0000DF;
background-color:#00FFFF;
border:none;
}
-->
</style>
<script type="text/javascript">
<!--
function Fensterweite()
{
if (window.innerWidth) return window.innerWidth;
else if (document.body && document.body.clientWidth) return document.body.clientWidth;
else return 0;
}
function Fensterhoehe()
{
if (window.innerHeight) return window.innerWidth;
else if (document.body && document.body.clientHeight) return document.body.clientHeight;
else return 0;
}
function neuAufbau()
{
if (Weite != Fensterweite()
Hoehe != Fensterhoehe())
window.history.go(0);
}
/*Überwachung von Netscape/Mozilla initialisieren*/
if(!window.Weite && window.innerWidth)
{
window.onresize = neuAufbau;
Weite = Fensterweite();
Hoehe = Fensterhoehe();
}
//-->
</script>
</head>
<body width="750px" height="500px" text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">
<script type="text/javascript">
<!--
/*Überwachung von MS Internet Explorer initialisieren*/
if(!window.Weite && document.body && document.body.clientWidth)
{
window.onresize = neuAufbau;
Weite = Fensterweite();
Hoehe = Fensterhoehe();
}
//-->
</script>
<div id="Beispiel" style="position:absolute;top:3%;left:60%;width:20%;background-color:#FF7F7F;border:none;">
<script type="text/javascript">
<!--
document.write("Weite: "+Weite +" Höhe: "+Hoehe);
//-->
</script>
</div>
<p id="txt">
<SPAN STYLE="font-weight:900";>
So reagieren die Browser:
</SPAN>
IE 5.0 / 5.5 / 6.02: Korrekt bei Weite und Höhe
Opera 7.0:
Opera 7.54: Weite: ok, Höhe = Weite das ist falsch
Mozilla 1.2.1:
Mozilla 1.7.3: Weite: ok, Höhe = Weite das ist falsch
Mozilla Firefox: Keine Reaktion auf Veränderung der Weite, erst nach reLoad
Netscape 4.7:
Netscape 7.1: Weite: ok, Höhe = Weite das ist falsch
</p>
</body></html>