我想在瀏覽器中顯示一個DOM節點樹,並帶有可摺疊的子節點。我正在尋找與FireBug的「html」選項卡幾乎相同的功能,只有我希望它在瀏覽器窗口內,並且我希望能夠選擇任意節點作爲根。在我自己寫作之前,我想我會檢查一下,確保沒有人能指向我已經寫好的一個。節點資源管理器腳本?
2
A
回答
1
我會找螢火蟲精簡版,螢火蟲的一個特殊版本實現了所有的Javascript,以便對下的瀏覽器,如Internet Explorer使用: http://www.getfirebug.com/lite.html
它幾乎正是你想要的(我認爲),即使它不是,它應該足夠接近,讓你從一開始。
0
傷了寫我自己的。它使用jQuery(我在下面稱之爲$ jq)。
nodeExplorer = function(node, container){ // note: container must be a jquery object
$jq(".nodeExplorerNode").live("click", function(){
$jq(this).toggleClass("collapsed");
return false;
});
if($jq("#nodeExplorerStyles").length == 0){
$jq("body").append(
"<style id='nodeExplorerStyles'>"+
".collapsed .nodeExplorerNode{"+
"display:none" +
"}"+
".collapsed>.minus{"+
"display:none" +
"}"+
".collapsed>.plus{"+
"display:inline" +
"}"+
".plus{"+
"display:none" +
"}"+
".nodeExplorerNode{"+
"cursor: pointer" +
"}"+
"</style>"
)
};
var drawNodes = function(node, container){
if(node.tagName){
container = $jq("<div style='margin-left: 20px' class='collapsed nodeExplorerNode'><span class='minus'>- </span><span class='plus'>+ </span>"+ node.tagName +" </div>").appendTo(container);
}else if(node.data){
container.append("<b>" + node.data + "</b>");
}
for(var i=0; i< node.childNodes.length; i++){
drawNodes(node.childNodes[i], container)
}
}
drawNodes(node, container);
}
相關問題
- 1. 紗線,節點管理器和資源管理器
- 2. 資源管理器
- 3. 項目節點上的團隊資源管理器2010錯誤?
- 4. VS SQL Server對象資源管理器永久加載節點
- 5. 資源管理器和節點管理器可以在同一個節點中嗎? [MapR]
- 6. 記事本+資源管理器插件
- 7. 警告腳本無法在資源管理器11上工作
- 8. Microsoft Azure CosmostDB腳本資源管理器console.log
- 9. VBScript:關閉Windows資源管理器時停止腳本
- 10. Coherence資源管理器
- 11. 在Windows資源管理器
- 12. PyDev包資源管理器
- 13. Azure資源管理器
- 14. 在Windows資源管理器
- 15. 資源管理器集成
- 16. Eclipse CVS資源管理器
- 17. 資源管理
- 18. 節點版本管理器在Windows
- 19. Android中的文件資源管理器像Windows資源管理器
- 20. VS代碼 - 文件資源管理器/資源管理器更改案例
- 21. Visual Studio 2013中的服務器資源管理器缺少Azure存儲節點
- 22. TFS項目在源代碼管理資源管理器中可見,但不在團隊資源管理器中?
- 23. VS2012 - 在特定項目/節點處打開源代碼管理資源管理器
- 24. 詹金斯的資源管理外部節點進行測試
- 25. JPA實體管理器資源處理
- 26. Windows資源管理器和重新分析點文件:保持資源管理器不打開我的文件
- 27. XmlPullParser資源管理
- 28. Impala資源管理
- 29. AngularJS資源管理
- 30. XTEND - 資源管理
感謝Michineghost! – morgancodes 2009-05-21 18:23:16