Expert Developer JavaScript Question:
Download Job Interview Questions and Answers PDF
How to get height and width of different browser in Javascript?
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;
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 Question | Next Question |
What are the different types of errors supported by JavaScript? | How to manage exception handling in Javascript? |