日期:2014-05-16  浏览次数:20456 次

求教JSTREE添加的超链接为何失效
JScript code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0037)http://2school.wygk.cn/admin/main.asp -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <META http-equiv="Content-Type" content="text/html"; charset="utf-8">
    <title>left</title>
    <script type="text/javascript" src="JS/jquery.js"></script>    
    <script type="text/javascript" src="JS/jquery.tree.js"></script>
     <script type="text/javascript" class="source">
    $(function () { 
        $("#browser").tree();
    });
        
      </script>    
    <link type="text/css" rel="stylesheet" href="CSS/style.css"/>
    <style type="text/css">
    body {background-image:url(images/left_bg.gif); margin:0; padding:0;color:white }
    body, td, th, pre, code, select, option, input, textarea {font-size:12px; }
    #container {  MARGIN: 0px; width:100%;
    background-color:transparent;
    }
    .demo { height:100%; width:100%; float:left; margin:0;font-family:Arial, Helvetica, sans-serif; font-size:12px; background-color:transparent; overflow:auto; }
    .syntaxhighlighter { margin:0 0 0 0 !important; padding:0 !important; }
    </style>
    
</head>
<body>
    <div id="browser"  class="demo source">
   <ul>
            <LI><A href="syscome.htm"
            target=frmright><ins>&nbsp;</ins>门户管理</A>
            <ul>
              <li><A href="syscome.htm" 
             target=frmright>新闻管理</A> 
             <ul>
             <li><a href="http://www.163.com">增加新闻</a></li>
             <li><a href="syscome.htm">删除新闻</a></li>
             <li><a href="syscome.htm">修改新闻</a></li>             
             </ul>
...................



在browser层里面设置的超链接不管单独测试还是放在iframe里面测试都无法跳转页面。把鼠标移到选择项上可以看到链接的网址,但点上去没有反应。

------解决方案--------------------
onchange : function (NODE) {
document.location.href = $(NODE).children("a:eq(0)").attr("href");
}

------解决方案--------------------
jquery.tree.js 冲突

里面包含了

return false;

阻止浏览器行为 

正确方法:

$('#browser li').each(function(){
$(this).find('a').click(function(){
var href = $(this).attr('href');
document.location.href = href ;
})
})