Get browser width and height

B

bruce barker

this is done with javascript, then the results must be posted back to
the server usually in hidden fields. you can render a "sniffer" page
that auto postbacks. the actual javascript code depends on the browser:

var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var height = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

-- bruce (sqlwork.com)
 
H

Herfried K. Wagner [MVP]

bruce barker said:
this is done with javascript, then the results must be posted back to the
server usually in hidden fields. you can render a "sniffer" page that auto
postbacks. the actual javascript code depends on the browser:

var width = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var height = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

However, be aware that there are Web browsers which do not support
JavaScript!
 
B

bruce barker

even those that support javascript can has it disabled. that why you use
a meta tag to refresh, allowing you to detect this. also if there is no
javascript, can not know the size.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top