1,如何在javasript建立超連結
<script type="text/JavaScript">
//方法一:
location.href='網址';
//方法二:
document.write('<a href="網址">文字</a>');
</script>
2,應用到Ext中的樹控制項事件處理
tree_03.js
複製代碼 代碼如下:Ext.onReady(function(){
var root = new Ext.tree.TreeNode({ //tree,這裡沒有function,使用json格式
id:1,
text:"linjq"
});
var c1 = new Ext.tree.TreeNode({
text:"child 1"
});
root.appendChild(c1);
root.appendChild(new Ext.tree.TreeNode({
text:"child 2"}));
var tree = new Ext.tree.TreePanel({
width:100,
renderTo:"content",
root:root
});
// c1.on("click",function(node,event){alert(node.text);});
// c1.on("click",function(){document.write('<a href="index.jsp">index.jsp</a>')});
c1.on("click",function(){location.href="index.jsp"});
});
複製代碼 代碼如下:<link type="text/css" rel="stylesheet" href="ext/resources/css/ext-all.css" />
<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>
<script type="text/javascript" src="tree_03.js"></script>
</head>
<body>
<div id="content"></div>
</body>