关于【梅花雪】的树,请教! MzTreeView.currentNode 树节点 只读,树当前得到焦点的节点对象 保存到cookie自己想吧MzTreeView.focus(id) 聚集到某个节点上 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1. var sid = tree.currentNode.sourceIndex;var id = sid.substr(sid.indexOf(tree.divider)+ tree.divider.length);你把这个 id 存在 cookie 里即可。2.setTimeout("tree.focus('"+ id +"')", 50); 再次请教【梅花雪】: 你们说得办法我试过了,不行,可能是我的水平太差领会不了,还望大师详细说明,恳请!请问有无现成的例子以供参考?另外,继续请教:我现在有一个框架网页:leftFrame:一棵树形结构的目录树使用的是MxTreeView1.0控件rightFrame:一篇百多万字的文章,一次性读入目录树中节点链接指向文章中的各个书签,我想在浏览文章过程中,保存当前聚集节点的ID于Cookies中,下次读者打开页面,TreeView展开后聚集到该节点,同时文章内容自动定位于相应的书签链接.在此案例中需要获得当前聚集节点对应的链接地址或脚本语句.请问【梅花雪】先生以上效果如何实现?我搜索了您回复的所有帖子,没有找到类似的,恳请指教.本人的JavaScript不好,万望详述! <html><head><title>梅花雪中文网 - 网页脚本控件集 MzTreeView10</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="author" content="黄方荣(meizz·梅花雪)://www.meizz.com"><script language="JavaScript" src="MzTreeView10.js"></script><link href="Script&Css/Global.css" type="text/css" rel="stylesheet"><style><!--A.MzTreeview{font-size: 9pt;padding-left: 3px;}--></style></head> <body><div id="MzTree"></div><script type="text/javascript"><!--window.tree = new MzTreeView("tree");tree.setIconPath("./");tree.nodes['-1_1'] = 'text:节点 1; url: topic.htm#1';tree.nodes['1_2'] = 'text:节点 2; url: topic.htm#2';tree.nodes['1_3'] = 'text:节点 3; url: topic.htm#3';tree.nodes['1_4'] = 'text:节点 4; url: topic.htm#4';tree.nodes['1_5'] = 'text:节点 5; url: topic.htm#5';tree.nodes['1_6'] = 'text:节点 6; url: topic.htm#6';tree.nodes['1_7'] = 'text:节点 7; url: topic.htm#7';tree.nodes['1_8'] = 'text:节点 8; url: topic.htm#8';tree.nodes['1_9'] = 'text:节点 9; url: topic.htm#9';tree.nodes['1_10'] = 'text:节点 10; url: topic.htm#10';tree.nodes['12_11'] = 'text:节点 11; url: topic.htm#11';tree.nodes['23_12'] = 'text:节点 12; url: topic.htm#12';tree.nodes['2_13'] = 'text:节点 13; url: topic.htm#13';tree.nodes['8_14'] = 'text:节点 14; url: topic.htm#14';tree.nodes['3_15'] = 'text:节点 15; url: topic.htm#15';tree.nodes['6_16'] = 'text:节点 16; url: topic.htm#16';tree.nodes['3_17'] = 'text:节点 17; url: topic.htm#17';tree.nodes['7_18'] = 'text:节点 18; url: topic.htm#18';tree.nodes['13_19'] = 'text:节点 19; url: topic.htm#19';tree.nodes['20_20'] = 'text:节点 20; url: topic.htm#20';tree.nodes['7_21'] = 'text:节点 21; url: topic.htm#21';tree.nodes['8_22'] = 'text:节点 22; url: topic.htm#22';tree.nodes['25_23'] = 'text:节点 23; url: topic.htm#23';tree.nodes['7_24'] = 'text:节点 24; url: topic.htm#24';tree.nodes['5_25'] = 'text:节点 25; url: topic.htm#25';tree.nodes['9_26'] = 'text:节点 26; url: topic.htm#26';tree.nodes['5_27'] = 'text:节点 27; url: topic.htm#27';tree.nodes['6_28'] = 'text:节点 28; url: topic.htm#28';tree.nodes['5_29'] = 'text:节点 29; url: topic.htm#29';tree.nodes['5_30'] = 'text:节点 30; url: topic.htm#30';tree.nodes['11_31'] = 'text:节点 31; url: topic.htm#31';tree.nodes['11_32'] = 'text:节点 32; url: topic.htm#32';tree.nodes['6_33'] = 'text:节点 33; url: topic.htm#33';tree.nodes['2_34'] = 'text:节点 34; url: topic.htm#34';tree.nodes['3_35'] = 'text:节点 35; url: topic.htm#35';tree.nodes['6_36'] = 'text:节点 36; url: topic.htm#36'; tree.setTarget("_blank");document.getElementById('MzTree').innerHTML = tree.toString();//下面这段代码就是为你的功能而扩充的代码function setCookie(name,value){ var Days = 30; //此 cookie 将被保存 30 天 var exp = new Date(); //new Date("December 31, 9998"); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString();}function getCookie(name){ var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null;}function delCookie(name){ var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=getCookie(name); if(cval!=null) document.cookie=name +"="+cval+";expires="+exp.toGMTString();}if(!window.attachEvent && window.addEventListener){ Window.prototype.attachEvent = HTMLDocument.prototype.attachEvent= HTMLElement.prototype.attachEvent=function(en, func, cancelBubble) { var cb = cancelBubble ? true : false; this.addEventListener(en.toLowerCase().substr(2), func, cb); };}window.attachEvent("onload", function(){ var id = getCookie("MTVSelectedId"); if(id) { setTimeout("tree.focus('"+ id +"', true); document.getElementById('tree_link_'+ tree.currentNode.id).click()", 20); }});window.attachEvent("onunload", function(){ var id= tree.currentNode.sourceIndex; id=id.substr(id.indexOf(tree.divider)+tree.divider.length); setCookie("MTVSelectedId", id);});//--></script> </body></html> "梅花欢喜漫天雪"谢谢梅花雪先生!非常感谢.代码作的很好,只是tree.nodes['-1_1'] = 'text:节点 1; url: topic.htm#1';这一行中的字符 -1 必须修改为0,方可正常显示. 更进一步: 如果我想在MzTreeView页面中添加一个input按钮,按钮文字"继续阅读",达到这样的效果:1. 若读者是第一次浏览该页面,则此按钮不显示,页面按默认方式显示;2. 若是老读者(根据cookie判断),此按钮显示 (1) 点击按钮,TreeView展开后聚集到目标节点,同时文章内容自动定位于相应的书签链接; (2) 不点击按钮,则页面按默认方式显示.本人对JavaScript知之甚浅,还请梅花雪先生不厌其烦指点迷津.再谢! JS代码我曾经做过一点修改,就是把原来的 0 改成了 -1 不过,不要紧,你继续使用 0 没有问题你这个需求,只需要把 onload 里的那段代码拿出来单独成为一个函数用按钮调用即可。/*window.attachEvent("onload", function(){ var id = getCookie("MTVSelectedId"); if(id) { setTimeout("tree.focus('"+ id +"', true); document.getElementById('tree_link_'+ tree.currentNode.id).click()", 20); }});*/function reRead(){ var id = getCookie("MTVSelectedId"); if(id) { setTimeout("tree.focus('"+ id +"', true); document.getElementById('tree_link_'+ tree.currentNode.id).click()", 20); }}<input type="button" value="reRead" onclick="reRead()" /> 实在对不起,我这两天出发了,一直没能够登陆论坛. 梅花雪先生的回复,我已经用过了,非常棒,确实不愧为大师级. 再一次对meizz(梅花雪)表示感谢!!! 没JS文件啊 -_-#怎么运行可以出来 我把你代码直接复制到txt然后改后缀 出不来 没JS文件啊 -_-#怎么运行可以出来 我把你代码直接复制到txt然后改后缀 出不来 MzTreeView 1.0 是数据一次性加载,客户端节点异步展示的WEB脚本树。有关资料见如下位置:开发文档: http://www.meizz.com/Web/Article.asp?id=436控件下载: http://www.meizz.com/Web/Download/MzTreeView10.rar应用示例: http://www.meizz.com/Web/Demo/MzTreeView10.htm 几行javascript代码的兼容性问题 在IE7中不能调用WB.ExecWB打印控件显示“不安全的控件”的提示 jquery combobox和Array有冲突??? jquery大牛请进 onclick 如何设置<body>中的属性 高手请进 如何将word文档的内容导入到html页面中 高分相赠,请高手帮忙!!!(急) 几个广告JS,放到js文件中失效,求指教 js调试问题 回复必给分:用javascript如何实现圆角的div 关于梅花雪菜单和树关联的疑问.
var sid = tree.currentNode.sourceIndex;
var id = sid.substr(sid.indexOf(tree.divider)+ tree.divider.length);
你把这个 id 存在 cookie 里即可。
2.
setTimeout("tree.focus('"+ id +"')", 50);
你们说得办法我试过了,不行,可能是我的水平太差领会不了,还望大师详细说明,恳请!
请问有无现成的例子以供参考?另外,继续请教:
我现在有一个框架网页:
leftFrame:一棵树形结构的目录树使用的是MxTreeView1.0控件
rightFrame:一篇百多万字的文章,一次性读入
目录树中节点链接指向文章中的各个书签,我想在浏览文章过程中,保存当前聚集节点的ID于Cookies中,下次读者打开页面,TreeView展开后聚集到该节点,同时文章内容自动定位于相应的书签链接.
在此案例中需要获得当前聚集节点对应的链接地址或脚本语句.请问【梅花雪】先生以上效果如何实现?
我搜索了您回复的所有帖子,没有找到类似的,恳请指教.本人的JavaScript不好,万望详述!
<head>
<title>梅花雪中文网 - 网页脚本控件集 MzTreeView10</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="author" content="黄方荣(meizz·梅花雪)://www.meizz.com">
<script language="JavaScript" src="MzTreeView10.js"></script>
<link href="Script&Css/Global.css" type="text/css" rel="stylesheet">
<style>
<!--
A.MzTreeview{font-size: 9pt;padding-left: 3px;}
-->
</style>
</head> <body>
<div id="MzTree"></div>
<script type="text/javascript">
<!--
window.tree = new MzTreeView("tree");
tree.setIconPath("./");
tree.nodes['-1_1'] = 'text:节点 1; url: topic.htm#1';
tree.nodes['1_2'] = 'text:节点 2; url: topic.htm#2';
tree.nodes['1_3'] = 'text:节点 3; url: topic.htm#3';
tree.nodes['1_4'] = 'text:节点 4; url: topic.htm#4';
tree.nodes['1_5'] = 'text:节点 5; url: topic.htm#5';
tree.nodes['1_6'] = 'text:节点 6; url: topic.htm#6';
tree.nodes['1_7'] = 'text:节点 7; url: topic.htm#7';
tree.nodes['1_8'] = 'text:节点 8; url: topic.htm#8';
tree.nodes['1_9'] = 'text:节点 9; url: topic.htm#9';
tree.nodes['1_10'] = 'text:节点 10; url: topic.htm#10';
tree.nodes['12_11'] = 'text:节点 11; url: topic.htm#11';
tree.nodes['23_12'] = 'text:节点 12; url: topic.htm#12';
tree.nodes['2_13'] = 'text:节点 13; url: topic.htm#13';
tree.nodes['8_14'] = 'text:节点 14; url: topic.htm#14';
tree.nodes['3_15'] = 'text:节点 15; url: topic.htm#15';
tree.nodes['6_16'] = 'text:节点 16; url: topic.htm#16';
tree.nodes['3_17'] = 'text:节点 17; url: topic.htm#17';
tree.nodes['7_18'] = 'text:节点 18; url: topic.htm#18';
tree.nodes['13_19'] = 'text:节点 19; url: topic.htm#19';
tree.nodes['20_20'] = 'text:节点 20; url: topic.htm#20';
tree.nodes['7_21'] = 'text:节点 21; url: topic.htm#21';
tree.nodes['8_22'] = 'text:节点 22; url: topic.htm#22';
tree.nodes['25_23'] = 'text:节点 23; url: topic.htm#23';
tree.nodes['7_24'] = 'text:节点 24; url: topic.htm#24';
tree.nodes['5_25'] = 'text:节点 25; url: topic.htm#25';
tree.nodes['9_26'] = 'text:节点 26; url: topic.htm#26';
tree.nodes['5_27'] = 'text:节点 27; url: topic.htm#27';
tree.nodes['6_28'] = 'text:节点 28; url: topic.htm#28';
tree.nodes['5_29'] = 'text:节点 29; url: topic.htm#29';
tree.nodes['5_30'] = 'text:节点 30; url: topic.htm#30';
tree.nodes['11_31'] = 'text:节点 31; url: topic.htm#31';
tree.nodes['11_32'] = 'text:节点 32; url: topic.htm#32';
tree.nodes['6_33'] = 'text:节点 33; url: topic.htm#33';
tree.nodes['2_34'] = 'text:节点 34; url: topic.htm#34';
tree.nodes['3_35'] = 'text:节点 35; url: topic.htm#35';
tree.nodes['6_36'] = 'text:节点 36; url: topic.htm#36'; tree.setTarget("_blank");
document.getElementById('MzTree').innerHTML = tree.toString();//下面这段代码就是为你的功能而扩充的代码
function setCookie(name,value)
{
var Days = 30; //此 cookie 将被保存 30 天
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString();
}
function getCookie(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie=name +"="+cval+";expires="+exp.toGMTString();
}
if(!window.attachEvent && window.addEventListener)
{
Window.prototype.attachEvent = HTMLDocument.prototype.attachEvent=
HTMLElement.prototype.attachEvent=function(en, func, cancelBubble)
{
var cb = cancelBubble ? true : false;
this.addEventListener(en.toLowerCase().substr(2), func, cb);
};
}
window.attachEvent("onload", function()
{
var id = getCookie("MTVSelectedId");
if(id)
{
setTimeout("tree.focus('"+ id +"', true); document.getElementById('tree_link_'+ tree.currentNode.id).click()", 20);
}
});
window.attachEvent("onunload", function()
{
var id= tree.currentNode.sourceIndex;
id=id.substr(id.indexOf(tree.divider)+tree.divider.length);
setCookie("MTVSelectedId", id);
});
//-->
</script>
</body>
</html>
谢谢梅花雪先生!非常感谢.代码作的很好,只是
tree.nodes['-1_1'] = 'text:节点 1; url: topic.htm#1';
这一行中的字符 -1 必须修改为0,方可正常显示.
如果我想在MzTreeView页面中添加一个input按钮,按钮文字"继续阅读",达到这样的效果:
1. 若读者是第一次浏览该页面,则此按钮不显示,页面按默认方式显示;
2. 若是老读者(根据cookie判断),此按钮显示
(1) 点击按钮,TreeView展开后聚集到目标节点,同时文章内容自动定位于相应的书签链接;
(2) 不点击按钮,则页面按默认方式显示.
本人对JavaScript知之甚浅,还请梅花雪先生不厌其烦指点迷津.再谢!
你这个需求,只需要把 onload 里的那段代码拿出来单独成为一个函数用按钮调用即可。/*
window.attachEvent("onload", function()
{
var id = getCookie("MTVSelectedId");
if(id)
{
setTimeout("tree.focus('"+ id +"', true); document.getElementById('tree_link_'+ tree.currentNode.id).click()", 20);
}
});
*/
function reRead()
{
var id = getCookie("MTVSelectedId");
if(id)
{
setTimeout("tree.focus('"+ id +"', true); document.getElementById('tree_link_'+ tree.currentNode.id).click()", 20);
}
}<input type="button" value="reRead" onclick="reRead()" />
梅花雪先生的回复,我已经用过了,非常棒,确实不愧为大师级.
再一次对meizz(梅花雪)表示感谢!!!
-_-#
怎么运行可以出来 我把你代码直接复制到txt然后改后缀 出不来
-_-#
怎么运行可以出来 我把你代码直接复制到txt然后改后缀 出不来
控件下载: http://www.meizz.com/Web/Download/MzTreeView10.rar
应用示例: http://www.meizz.com/Web/Demo/MzTreeView10.htm