i need to find out the inner width of a browser window. i'm using window.innerWidth for ns4.x and it works fine.
for ie i am trying to use document.body.clientWidth, but i get an error saying "document.body.clientWidth is not an object" (on a mac) or "objet expected" (on a pc). I have also tried using document.getElementById('body').clientWidth, but it would generate the same error message.
i finally went to javascriptkit.com wherethere is a tutorial on "Using JavaScript to statically display elements" (http://javascriptkit.com/javatutors/static.shtml) and it says there to use the same expressions I am using. On page 3 of teh tutorial (http://javascriptkit.com/javatutors/static3.shtml) there is an example that actually utilizes document.body.clientWidth and it works in my browser with no error messages whatsoever. so why would teh same expression give me an error on another page? the page was working fine before document.body.clientWidth was added to it, so I know it is not an error from something above that piece of code.
here's the script:
am i just not seeing something obvious???
for ie i am trying to use document.body.clientWidth, but i get an error saying "document.body.clientWidth is not an object" (on a mac) or "objet expected" (on a pc). I have also tried using document.getElementById('body').clientWidth, but it would generate the same error message.
i finally went to javascriptkit.com wherethere is a tutorial on "Using JavaScript to statically display elements" (http://javascriptkit.com/javatutors/static.shtml) and it says there to use the same expressions I am using. On page 3 of teh tutorial (http://javascriptkit.com/javatutors/static3.shtml) there is an example that actually utilizes document.body.clientWidth and it works in my browser with no error messages whatsoever. so why would teh same expression give me an error on another page? the page was working fine before document.body.clientWidth was added to it, so I know it is not an error from something above that piece of code.
here's the script:
Code:
var wdth if (document.layers) { wdth = window.innerWidth alert(wdth) } else { wdth = document.body.clientWidth alert(wdth) }
Comment