Shuvro Akash
Shuvro Akash

Reputation: 567

Is it possible to calculate empty area of a html page?

I need the empty area of a html page.

enter image description here

How can i calculate the red marked are using javascript? Sorry if my question is silly

Upvotes: 0

Views: 231

Answers (3)

Spencer May
Spencer May

Reputation: 4505

You want the distance of the HTML document minus the height of the screen:

var html = document.documentElement;
var doc_height = Math.max(html.clientHeight, html.scrollHeight, html.offsetHeight);
var height = (screen.height > doc_height ? screen.height-doc_height : 0); //if the space exists, else return 0

Upvotes: 1

grendeld
grendeld

Reputation: 116

If you need to do it with javascript then you can use the above comment to find classes. If you just need the areas in general most browsers will have pixel ruler extensions that will help you with width and height measurements.

[chrome ruler extension[1]

Upvotes: 0

Ranjeet
Ranjeet

Reputation: 579

Red mark area will have a particular class.You can use

CODE

document.getElementByClassname('.className').clientHeight;

Upvotes: 0

Related Questions