JAKARTAPROJECT
JAKARTA TIPJSP TIPJSP Áú¹®&´äº¯DATABASE TIPJAVASCRIPT TIPWEBHACKING TIP±âŸ TIP
ÀÚ¹Ù½ºÅ©¸³Æ® ÆÁ
ÀÚ¹Ù½ºÅ©¸³Æ® ÆÁ
ÀÚ¹Ù½ºÅ©¸³Æ® ¹× CSS ÆÁ °Ô½ÃÆÇÀÔ´Ï´Ù
Scrollable HTML table
GoodBug http://www.jakartaproject.com
À̹ÌÁö ½½¶óÀÌ´õ º¸±â

Scrollable HTML table

Overview

Scrollable HTML table JavaScript code can be used to convert tables in ordinary HTML into scrollable ones. No additional coding is necessary. All you need to do is put header rows (if you need them) in THEAD section, table body rows in TBODY section, footer rows (if you need them) in TFOOT section and give your table an ID field, include the webtoolkit.scrollabletable.js file and create ScrollableTable() object after each table.

Scrollable HTML table code tested in IE5.0+, FF1.5+.

 

Source code for index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Scrollable HTML table</title>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="webtoolkit.scrollabletable.js"></script>

    <style>
        table {
            text-align: left;
            font-size: 12px;
            font-family: verdana;
            background: #c0c0c0;
        }

        table thead {
            cursor: pointer;
        }

        table thead tr,
        table tfoot tr {
            background: #c0c0c0;
        }

        table tbody tr {
            background: #f0f0f0;
        }

        td, th {
            border: 1px solid white;
        }
    </style>
</head>

<body>

<table cellspacing="1" cellpadding="2" class="" id="myScrollTable" width="400">
    <thead>
        <tr>
            <th class="c1">Name</th>
            <th class="c2">Surename</th>
            <th class="c3">Age</th>
        </tr>
    </thead>

    <tbody>
        <tr class="r1">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">30</th>
        </tr>
        <tr class="r2">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">31</th>
        </tr>
        <tr class="r1">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">32</th>
        </tr>
        <tr class="r2">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">33</th>
        </tr>
        <tr class="r1">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">34</th>
        </tr>
        <tr class="r2">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">35</th>
        </tr>
        <tr class="r1">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">36</th>
        </tr>
        <tr class="r2">
            <td class="c1">John</th>
            <td class="c2">Smith</th>
            <td class="c3">37</th>
        </tr>
    </tbody>

    <tfoot>
        <tr>
            <th class="c1">Name</th>
            <th class="c2">Surename</th>
            <th class="c3">Age</th>
        </tr>
    </tfoot>
</table>

<script type="text/javascript">
var t = new ScrollableTable(document.getElementById('myScrollTable'), 100);
</script>

</body>
</html>

 

Source code for webtoolkit.scrollabletable.js

/**
*
* Scrollable HTML table
* http://www.webtoolkit.info/
*
**/

function ScrollableTable (tableEl, tableHeight, tableWidth) {

    this.initIEengine = function () {

        this.containerEl.style.overflowY = 'auto';
        if (this.tableEl.parentElement.clientHeight - this.tableEl.offsetHeight < 0) {
            this.tableEl.style.width = this.newWidth - this.scrollWidth +'px';
        } else {
            this.containerEl.style.overflowY = 'hidden';
            this.tableEl.style.width = this.newWidth +'px';
        }

        if (this.thead) {
            var trs = this.thead.getElementsByTagName('tr');
            for (x=0; x<trs.length; x++) {
                trs[x].style.position ='relative';
                trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
            }
        }

        if (this.tfoot) {
            var trs = this.tfoot.getElementsByTagName('tr');
            for (x=0; x<trs.length; x++) {
                trs[x].style.position ='relative';
                trs[x].style.setExpression("bottom", "(this.parentElement.parentElement.offsetHeight - this.parentElement.parentElement.parentElement.clientHeight - this.parentElement.parentElement.parentElement.scrollTop) + 'px'");
            }
        }

        ;


}

 

http://www.webtoolkit.info/scrollable-html-table.html

 

2008-01-16 00:26:06
220.70.88.***

 

ÁÁÀº»ý°¢ ^^

÷ºÎÆÄÀÏ (ÃÑ 2°³)
  1. index.html 2.04 KB (116 ´Ù¿î·Îµå)
  2. webtoolkit_scrollabletable.js 3.31 KB (108 ´Ù¿î·Îµå)
0Á¡ (0¸í)
µ¡±Û 0°³ | ÅÂ±× 1°³ | °ü·Ã±Ûº¸±â
ű×ÀÔ·Â
½±Ç¥(,)±¸ºÐÀ¸·Î Çѹø¿¡ ¿©·¯ ű׸¦ ÀÔ·ÂÇÒ¼ö ÀÖ½À´Ï´Ù
scrollable table (1)
À̸§ ºñ¹Ð¹øÈ£
ÀÚ¹Ù½ºÅ©¸³Æ® ÆÁ
ÀÚ¹Ù½ºÅ©¸³Æ® ¹× CSS ÆÁ °Ô½ÃÆÇÀÔ´Ï´Ù
! ¹øÈ£ Á¦¸ñ ±Û¾´ÀÌ ÀÏÀÚ Á¶È¸
220 img À̹ÌÁö ºÎµå·´°Ô ÁÙÀ̱â 1 GoodBug 2009-12-18 8,193
219 rss xml ÆĽÌÇÏ´Â ¸ðµâ ÀÔ´Ï´Ù. 1 °í°í½Ì 2009-11-27 7,641
218 Æ®¸® ÀÔ´Ï´Ù . 1 °í°í½Ì 2009-11-27 5,873
217 ¿¡·¯Ã³¸® 1 kaiser 2009-05-11 6,088
216 À¥ÆäÀÌÁö º¹»ç ¹æÁö ÇØÁö ÇÏ´Â ¹ý kaiser 2009-05-03 11,673
215 javascript ÇÑ±Û Â¥¸£±â 1 1 kaiser 2008-08-14 7,985
214 rolling ·Ñ¸µ ½ºÅ©¸³Æ® 1 2 GoodBug 2008-07-11 10,128
213 alert ¸Þ½ÃÁö¸¦ print ó·³ »ç¿ëÇϱâ 2 °í°í½Ì 2008-06-10 8,675
212 onload onload Æã¼ÇÀÌ Á¤ÀǵǾî ÀÖ´Â »óȲ¿¡¼­ onload¿¡ Ãß°¡Çϱâ 1 GoodBug 2008-04-11 8,440
211 javascript ÀÚ¹Ù½ºÅ©¸³Æ® °³¹ß°¡À̵å 4 1 kaiser 2008-04-09 8,898
210 escape HTML escpae code 1 GoodBug 2008-04-02 6,499
209 optgroup SELECT ¸ñ·Ï ±×·ìº°·Î ¹­±â 1 1 GoodBug 2008-03-06 8,215
208 µ¿Àû Å×À̺í Å×ÀÌºí¿¡ µ¿Àû TR »ðÀÔ ¹× »èÁ¦ IE, FF °ø¿ë 1 GoodBug 2008-01-18 11,745
207 drag Javascript drag and drop 1 1 GoodBug 2008-01-16 8,171
206 sort Sortable HTML table 2 GoodBug 2008-01-16 7,402
scrollable table Scrollable HTML table 1 GoodBug 2008-01-16 7,087
204 CSS CSS centered layout 1 1 GoodBug 2008-01-16 6,685
203 utf8 Javascript UTF-8 1 GoodBug 2008-01-16 7,914
202 encode Javascript url decode, encode 2 GoodBug 2008-01-16 8,159
201 ¾Ïȣȭ Javascript MD5 2 GoodBug 2008-01-15 7,364
copyright 2005-2024 by Unicorn