Created
July 29, 2013 09:49
-
-
Save lukejones/6103291 to your computer and use it in GitHub Desktop.
Detect browser height
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function browserHeight(){ | |
var headerHeight = $(window).height(); | |
$(".header").css('height',headerHeight); // I wanted to subtract pixels from this value, e.g. change 970px to 920px | |
}; | |
$(document).ready(browserHeight); |
You can use parseInt
to abstract the number.
var num = parseInt(headerHeight, 10); // => 970
var newNum = num - 70;
$(".header").css("height", newNum + "px"); // might not be required, jQuery defaults to px IIRC
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function browserHeight(){
var headerHeight = parseInt($(window).height()) - 50;
$(".header").css('height',headerHeight+'px'); // I wanted to subtract pixels from this value, e.g. change 970px to 920px
};
$(document).ready(browserHeight);