Detecting Window Size

They have: 6 posts

Joined: Nov 1999

Can you help?

Is it possible to detect the window size of the browser so I can make an image appear if less than a certain height. If yes, is this a one off check or will it activate if the user resizes the window.

Thanks in advance for any ideas....

They have: 74 posts

Joined: Sep 2000

do you want to check the window size or the size of the monitor, becuase you can CONTROL the size of the monitor, ill have to get back to you on that though... i have a really bad and annoying headache...

hehe

AndyB's picture

They have: 344 posts

Joined: Aug 1999

Put this in the HEAD section of your page. It displays the actual window size in the status window for both IE5 and NN4. I'll leave it to you to change the code to achieve the effect you need:)

<script type="text/javascript">

function checker(){

if (document.all)

{
w=document.body.clientWidth
h=document.body.clientHeight
window.status="Current dimensions: "+w+" x "+h
}

else

{
w=window.innerWidth
h=window.innerHeight
window.status="Current dimensions: "+w+" x "+h
}

}
setInterval("checker()",20)

</script>

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.