Forum Moderators: open

Message Too Old, No Replies

Calling a Function - Is this correct?

         

JAB Creations

6:25 am on Aug 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This little script works in Gecko and Opera and is intended to make a div that renders 100% the height and width minus a 10px margin on all four sides.

This script just executes ... what I am curios about is if I am properly calling the changeStyle function? I am unaware of any Javascript validator but I figured I may be missing something here as far as calling the function goes.

If you wish to test this out, just add div.body {#000 solid 1px} to the style...does not work in IE (not worried about that in this post though).

<script type="text/javascript">
<!--
function changeStyle()
{
myheight = document.getElementById("DivBody");
myheight.style = window.innerHeight-20;
mywidth = document.getElementById("DivBody");
mywidth.style = window.innerWidth-20;
}
function resizeDiv() {
}
document.writeln('<div id="DivBody" class="body">'); resizeDiv();
//-->
</script>

Bernard Marx

8:01 am on Aug 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




myheight = document.getElementById("DivBody");
myheight.style = window.innerHeight-20;

This can't be right!

myheight
holds a reference to the DIV. You then attempt to reassign its
style
property. Perhaps this...


document.getElementById("DivBody").style.height = window.innerHeight-20;

IE & Opera don't have a

window.innerHeight
property (as discussed prev).