MorningStar
MorningStar

Reputation: 176

Alert height of window

I'm trying to get the height of the window & document to display through an alert and also when a modal window pops up. I know I need to use $(window).height(); & $(document).height(); but other than that I'm not sure what to do.

Edit: The problem that I am trying to solve is that my modal window is adding extra pixels to the bottom of the document so I'm trying to find out the original document height and the height after the modal window is activated.

Upvotes: 0

Views: 11247

Answers (2)

dciso
dciso

Reputation: 1264

This would alert on load then if the user resizes the window alert again. With a bit more detail on what you want to do we could give a better example:

    function alertHeight() {        
        alert("Window Height: " + $(window).height() + ", Document Height: " + $(document).height());
    }

    $(window).load(function() {
         alertHeight();
    });

    $(window).resize(function() {
         alertHeight();             
    });

Upvotes: 3

Nate
Nate

Reputation: 30656

Something like this

alert($(window).height());

will show an alert with the height of the window.

Upvotes: 6

Related Questions