<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>emu</title>
</head>
<body>
<script language="javascript">
function CHAPTER(t,p)
{
this.chapter=[];
this.title = t;
this.page=p;
}var book= new CHAPTER("JavaScript:The Definitive Guide",0)
book.chapter[0]=new CHAPTER("Introduction",3);
book.chapter[1]=new CHAPTER("Lexical Structure",6);
book.chapter[0].chapter[0]=new CHAPTER("test1",3);
book.chapter[0].chapter[1]=new CHAPTER("test2",4);
book.chapter[1].chapter[0]=new CHAPTER("test3",6);
book.chapter[1].chapter[1]=new CHAPTER("test4",8);traverse(book)
function traverse(obj)
{
document.write(obj.title+"<br><BLOCKQUOTE>");
for (var i=0;i<obj.chapter.length;i++)
traverse(obj.chapter[i]);
document.write("</BLOCKQUOTE>");
}
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>emu</title>
</head>
<body>
<script language="javascript">
function CHAPTER(t,p)
{
this.chapter=[];
this.title = t;
this.page=p;
}var book= new CHAPTER("JavaScript:The Definitive Guide",0)
book.chapter[0]=new CHAPTER("Introduction",3);
book.chapter[1]=new CHAPTER("Lexical Structure",6);
book.chapter[0].chapter[0]=new CHAPTER("test1",3);
book.chapter[0].chapter[1]=new CHAPTER("test2",4);
book.chapter[1].chapter[0]=new CHAPTER("test3",6);
book.chapter[1].chapter[1]=new CHAPTER("test4",8);traverse(book)
function traverse(obj)
{
document.write(obj.title+"<br><BLOCKQUOTE>");
for (var i=0;i<obj.chapter.length;i++)
traverse(obj.chapter[i]);
document.write("</BLOCKQUOTE>");
}
</script>
</body>
</html>
解决方案 »
- 有没有用过火狐的js引擎spidermonkey的,请教个问题
- 滑块滚动操作
- js常见取值问题
- |zyciis|第二贴 200分求:如何判断一段HTML放进一个新建的DIV后,这个DIV的高和度是多少呢; ||为什么我的宽变小了,而高没有变大呢 谢谢
- 谁有js实现信息提示的代码?
- 求验证URL格式的正则谢谢
- 关于框架的使用
- 如何让textarea控件的滚动条怎是位与最下方?
- 50分求教,上传文件HTML控件的问题
- 请问关于document.all的问题~`
- 如何把网页中一个frame中的内容存储成一个单独的HTML文?
- 一款支持编辑html,css,js,vbs,asp,sql,vml,dhtml等语言的软件
{
var name="";
for(var i in obj)
{
if(typeof(i)==Object)
name +=traverse(i);
else
name += obj[i]+"\n";
}
return name;
}