Why is it that I am not able to put the following into a js file it never works

var available_height=document.body.clientHeight;

and then in the body tag add

document.write("Window Height " + available_height + "<BR>")

yet when I add

<script>
var available_height=document.body.clientHeight;
</script>

right into the body of the document it works?

can anyone explain this to me Please

Thanks