Expert Developer JavaScript Question: Download Expert JavaScript Developer PDF

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

Tweet Share WhatsApp

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 PDF Read All 150 Expert JavaScript Developer Questions
Previous QuestionNext Question
What are the different types of errors supported by JavaScript?How to manage exception handling in Javascript?