js style動(dòng)態(tài)設(shè)置table高度
更新時(shí)間:2014年10月21日 17:20:16 投稿:whsnow
設(shè)置table高度想必大家都會(huì),直接在table標(biāo)簽中設(shè)置下不就行了嗎?這是靜態(tài)的,如果要?jiǎng)討B(tài)設(shè)置你會(huì)嗎?下面的實(shí)例將教會(huì)大家
直接在table標(biāo)簽中設(shè)置下不就行了嗎?這是靜態(tài)的,如果要?jiǎng)討B(tài)設(shè)置你會(huì)嗎?
function com_onresize(){ var contentsHeight = document.body.clientHeight; var buttonsHeight = document.getElementById( "buttons" ).offsetHeight; var head1Height = document.getElementById( "head1" ).offsetHeight; var head2Height = document.getElementById( "head2" ).offsetHeight; var t1 = document.getElementById( "TableContainer1" ).style.height; var t2 = document.getElementById( "TableContainer2" ).style.height; //alert(document.getElementById( "TableContainer1" ).style.height); var h = contentsHeight - buttonsHeight - head1Height - head2Height - 13; if(h < 110){ return; } document.getElementById( "TableContainer1" ).style.height = h/2 + 'px'; document.getElementById( "TableContainer2" ).style.height = h/2 + 'px'; } function com_sbs_pagesize(){ var screenHeight = window.screen.height; var availHeight = window.screen.availHeight; //alert(document.getElementById( "TableContainer1" ).children[0].rows.length); var index = document.getElementById( "TableContainer1" ).children[0].rows.length var buttonsHeight = document.getElementById( "buttons" ).offsetHeight; var head1Height = document.getElementById( "head1" ).offsetHeight; var head2Height = document.getElementById( "head2" ).offsetHeight; var mainH = buttonsHeight + head1Height +head2Height + 13; //20:scroll 35:title 25:tr while ((availHeight-mainH) < (20 + 35 + 25*index)*2) { index = index - 1; } var tableHeight = 20 + 35 + 25*index; document.getElementById( "TableContainer1" ).style.height = tableHeight + 'px'; document.getElementById( "TableContainer2" ).style.height = tableHeight + 'px'; window.resizeTo(document.body.offsetWidth,mainH + tableHeight*2); }
相關(guān)文章
細(xì)說(shuō)webpack源碼之compile流程-rules參數(shù)處理技巧(1)
webpack作為一種流行的打包工具被廣泛應(yīng)用在web項(xiàng)目的前端工程化構(gòu)建中。下面通過(guò)本文給大家介紹webpack源碼之compile流程-rules參數(shù)處理技巧,感興趣的朋友一起看看吧2017-12-12JS實(shí)現(xiàn)的四級(jí)密碼強(qiáng)度檢測(cè)功能示例
這篇文章主要介紹了JS實(shí)現(xiàn)的四級(jí)密碼強(qiáng)度檢測(cè)功能,具有實(shí)時(shí)檢測(cè)輸入密碼強(qiáng)度的功能,涉及javascript針對(duì)字符串的正則判定相關(guān)操作技巧,需要的朋友可以參考下2017-05-05

用js統(tǒng)計(jì)用戶下載網(wǎng)頁(yè)所需時(shí)間的腳本
下面的方法是個(gè)不錯(cuò)的思路,建議對(duì)于js感興趣的朋友,推薦看
2008-10-10 
JS跳出循環(huán)的方法區(qū)別對(duì)比分析(break,continue,return)
面向?qū)ο缶幊陶Z(yǔ)法中我們會(huì)碰到break ,continue, return這三個(gè)常用的關(guān)鍵字,那么關(guān)于這三個(gè)關(guān)鍵字的使用具體的操作是什么呢?接下來(lái)通過(guò)本文給大家講解JS跳出循環(huán)的方法區(qū)別對(duì)比分析(break,continue,return),感興趣的朋友一起看看吧
2023-02-02 
JavaScript給數(shù)組添加元素的6個(gè)方法
本文主要介紹了JavaScript給數(shù)組添加元素的6個(gè)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
2022-08-08