Expert Developer JavaScript Question: Download Questions PDF
How to get height and width of different browser in Javascript?
![Expert JavaScript Developer Interview Answer Expert JavaScript Developer Interview Question](https://globalguideline.com/public/images/interview/22.png)
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? |