[JS] innerHeight / clientHeight + Mozilla?

Pagina: 1
Acties:

  • oZy
  • Registratie: Juli 2001
  • Laatst online: 21-08 15:17
Kort vraagje..
JavaScript:
1
2
3
4
5
6
7
8
9
10
11
<script language="JavaScript"><!--
function textHeight() {
  if (document.all) {
    iHoogte = document.body.clientHeight
  } else {
    iHoogte = window.innerHeight;
  }
  document.all['content'].style.height = iHoogte - 264;
}
//--></script>
<body onLoad="textHeight();" onResize="textHeight();">

waarom reageert Mozilla 1.4 hier niet op (en geeft de console geen error) :?

[ Voor 14% gewijzigd door oZy op 11-08-2003 14:26 ]


  • jvreuls
  • Registratie: Januari 2002
  • Laatst online: 31-07 13:13
Omdat je document.all gebruikt en dat alleen in IE werkt.

In Mozilla (en ook IE5+) kun je het W3C DOM gebruiken (document.getElementById etc).

Circuits Online


  • oZy
  • Registratie: Juli 2001
  • Laatst online: 21-08 15:17
ah bleh, ik knip/plak het verkeerde script!
JavaScript:
1
2
3
4
5
6
7
8
9
10
11
12
<script language="JavaScript"><!--
function textHeight() {
  if (document.all) {
    iHoogte = document.body.clientHeight
    document.all['content'].style.height = iHoogte - 264;
  } else {
    iHoogte = window.innerHeight;
    document.getElementById("content").style.height = iHoogte - 264;
  }
}
//--></script></head>
<body onLoad="textHeight();" onResize="textHeight();">

dit werkt dus ook niet, krijg helemaal geen reactie van Mozilla

  • crisp
  • Registratie: Februari 2000
  • Laatst online: 14:11

crisp

Devver

Pixelated

JavaScript:
1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">

function textHeight() {

  var iHoogte = window.innerHeight || document.body.clientHeight;
  document.getElementById('content').style.height = (iHoogte-264)+'px';

}

</script>


zou in alle moderne browsers moeten werken :)

edit: en vergeet document.all, da's alleen nog maar voor IE4 support interessant ;)

edit2: vooral ook een type declaratie gebruiken in je script-tag, en die ranzige ueberoverbodige hide-this-script-from-older-browsers-dingetjes weglaten ;)

[ Voor 70% gewijzigd door crisp op 11-08-2003 14:42 ]

Intentionally left blank


  • Bosmonster
  • Registratie: Juni 2001
  • Laatst online: 19-08 22:14

Bosmonster

*zucht*

Samengevat, je bent de px vergeten. Mozilla kan niet ruiken welke eenheid je wilt gebruiken :)