0

I'm trying to get height from adjustable div because I'd like to add overflow style into css when height value will be greater than a set value. When you resize window height of this the div change. I'll explain this with some pictures:

http://imageshack.us/a/img801/2113/somethingo.png

http://imageshack.us/a/img7/7503/blebvle.png

The main problem is how to get it dynamically? I mean,when you resize your own window etc.?

Bruno Vieira
  • 3,794
  • 1
  • 21
  • 35
Robert Kazik
  • 13
  • 1
  • 5

2 Answers2

3

In case you are able to use jQuery, I would suggest using the window.onresize method and compute the height of the div.

$(document).ready(function()
{
   $(window).on("resize", function()
   {
        $("#myDiv").text("My height is " + $("#myDiv").height());
   });                                                           
});​

Take a look at this fiddle I created for you: http://jsfiddle.net/9ftGe/

I hope this is what you wanted.

David Müller
  • 5,093
  • 2
  • 23
  • 33
0

I think you're looking for monitoring the browser variables...

window.innerHeight

window.innerWidth

Whenever you check/call these variables you should get the exact window inner size and take it from there.

NB: These variables (constants to us) are case sensitive.

John Citizen
  • 164
  • 1
  • 10