Get browser width and height

  • Thread starter Thread starter Mate
  • Start date Start date
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)
 
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!
 
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)
 
Back
Top