2014-12-30 40 views
0
var wh = $(document.documentElement.clientHeight).height(); 
var tH = $('.a_Top').height(); 
var bH = $('.a_BottomBar_b').height(); 
$('.a_ContentOuter').css('min-height',(wh)+'px'); 
$('.a_ContentInner').css('min-height',(wh-(tH+bH+29))+'px'); 

我在一個函數編寫這些代碼,但是當我在Firefox中打開這個頁面,這將是一個錯誤,當我們在這整個代碼註釋會被罰款,所以請給我的建議,並幫助找到使用此代碼的正確方法....如何使用瀏覽器窗口的大小?

+5

「_it將是一個錯誤_」 - 什麼錯誤?請發佈您收到的錯誤。 –

+2

應該使用'$(window).height()'。 –

+2

'document.documentElement.clientHeight'是一個數字,如何創建一個數字的jQuery對象? – Teemu

回答

3

添加$(window).height();

var wh = $(window).height(); 
var tH = $('.a_Top').height(); 
var bH = $('.a_BottomBar_b').height(); 
$('.a_ContentOuter').css('min-height',(wh)+'px'); 
$('.a_ContentInner').css('min-height',(wh-(tH+bH+29))+'px'); 
alert($('.a_ContentOuter').css('min-height')); 
相關問題