Expert Developer JavaScript Question:

Download Job Interview Questions and Answers PDF

How to get height and width of different browser in Javascript?

Expert JavaScript Developer Interview Question
Expert JavaScript Developer Interview Question

Answer:

Following examples illustrate the different ways to get height and width of different browser.

For Non-IE:
var Width;
var Height;
Width = window.innerWidth;
Height = window.innerHeight;
For IE 6+ in standards compliant mode :
Width = document.documentElement.clientWidth;
Height = document.documentElement.clientHeight;

For IE 4 compatible:
Width = document.body.clientWidth;
Height = document.body.clientHeight;

Download Expert JavaScript Developer Interview Questions And Answers PDF

Previous QuestionNext Question
What are the different types of errors supported by JavaScript?How to manage exception handling in Javascript?