- 相關推薦
PHP應用:用XSLT輕松實現(xiàn)樹形折疊導航欄
每一發(fā)奮努力的背后,必有加倍的賞賜。以下百分網小編整理的用XSLT輕松實現(xiàn)樹形折疊導航欄的知識,希望對大家有所幫助,更多信息請關注應屆畢業(yè)生網!
展開和折疊實在就是顯示或不顯示display:none or block)它與可見與不可見(visible or invisible)是有差別的, 前者不在頁面預留空間。 這個toggle函數完成兩個功效, 轉變TR本來的Hidden屬性, 使本來不顯示的顯示; 轉變IMG的src屬性, 更改圖片。
toggle.js
function toggle(id)
{
var thisRow = document.all.item(id);
if (thisRow)
{
if (thisRow.getAttribute('Expanded') == 'yes')
{
thisRow.setAttribute('Expanded', 'no');
thisRow.children(0).children(0).children(0).src = 'images/bs.gif';
var allRows = document.all.tags('TR');
for (var i=1; i < allRows.length; i )
{
var row = allRows[i];
if (row.getAttribute('AncestorID') == id)
{
if (row.getAttribute('Expanded') == 'yes') {
toggle(row.getAttribute('id'));
}
row.className = 'Navigator-Hidden';
}
}
thisRow.className = 'Navigator';
}
else
{
thisRow.setAttribute('Expanded', 'yes');
thisRow.children(0).children(0).children(0).src = 'images/bo.gif';
var allRows = document.all.tags('TR');
var depth = parseInt(thisRow.getAttribute('Depth'));
for (var i=1; i < allRows.length; i )
{
var row = allRows[i];
if (row.getAttribute('AncestorID') == id &&
parseInt(row.getAttribute('Depth')) == depth 1 )
{
row.className = 'Navigator';
}
}
}
}
}
到此結束。
誠然這個TOC的功效還是最基礎的, 例如我還未做內容和目錄的同步,其中有的處所還可以修正, 對xml和xsl文件可以進一步瘦身。 不過對一般用戶來講, 這已經足夠了。
【PHP應用:用XSLT輕松實現(xiàn)樹形折疊導航欄】相關文章:
css就能實現(xiàn)簡單導航欄實例08-15
PHP的樹形結構算法07-06
如何制作簡單導航欄03-27
php:樹形結構的算法實例04-01
用PHP實現(xiàn)文件上傳二法05-10
php用cookie實現(xiàn)記住登錄狀態(tài)02-02
實現(xiàn)PHP實現(xiàn)限制IP訪問02-23
PHP無限分類(樹形類)的深入分析05-12
PHP編程與應用06-06