Question

I want to get the height of the viewport using ExtJs or native javascript.

How can i get this height ? I am not using any extjs viewport container.

If its not possible using ExtJs then how can i find the exact height of the view port ?

Thanks!!

Was it helpful?

Solution 2

How about

window.innerWidth
window.innerHeight

in ExtJS you can use getViewSize( )

Another plain JS approach is

This function will return any document height (cross-browser) and if the documents body height is less than the viewport height then it will return the viewport height instead. Cause I think your doc is empty at the time you check this should perfectly work for you.

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

OTHER TIPS

Using window.innerHeight solved my problem and also the ExtJs way of finding the view port height is as follows -

Ext.getBody().getViewSize().height
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top