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

新手 在线急求js大牛!!!
HTML code
<html>
    <head>
        <meta charset="gb2312" />
        <title></title>
        <script type="text/javascript" src="js/jquery-1.6.2.js" charset="GBK"></script>
        <style>
            #tip {
                display:none;
                position:absolute;
                width:32px; height:16px; line-height:16px; overflow:hidden;
                border:2px solid #000;
                background:#999;
                color:#fff; font-size:12px; font-weight:bold; text-align:center; cursor:pointer;
            }
        </style>
    </head>
    <body>
        选择下面的文字,进行备注。。。
        <div id="content">
           勒布朗-詹姆斯平生第一次捧起总冠军奖杯,今天他打出三双,贡献26分、11个篮板和13次助攻,当之无愧地成为总决赛MVP。<br />
           热火全场三分球25投14中,投中三分数平了总决赛纪录。<br />
        </div>
        <div id="tip">批注</div>
       <div id="tipanno"style="position: absolute; display: none; border: 1px; border-style: solid;">
<TABLE id="tipTable" border="0" bgcolor="#ffffee">
<TR align="center">
<TD>
</TD>
</TR>
<TR>
<TD></TD>
</TR>
<TR>
<TD></TD>
</TR>
</TABLE>
</div>
        <script>
            var datas = {   };
             $.post("jsontest.asp",function(data,states){
             alert(data);
             $.each(eval(data),function(i,item){
             var title = eval(data)[i].title;
             var content = eval(data)[i].content;
              if( !datas[title] ){
                     datas[title] = [];    
                   }
             datas[title].push(content);
              con.innerHTML = con.innerHTML.replace(title, '<a href="#" onmouseover="showTip('+content+')" onmouseout="hideTip()">'+title+'</a>');
             });
            //alert(eval(data));
})
            var tip = document.getElementById("tip");
            var con = document.getElementById("content");
            var targets=document.getElementById("tipanno");
            for(var key in datas){
                con.innerHTML = con.innerHTML.replace(key, '<a href="#" onmouseover="showTip(this.innerHTML)" onmouseout="hideTip()">'+key+'</a>');
            }
            
            function showTip(t){
            var x=event.clientX;//取得发生事件的x坐标点
 var y=event.clientY;
 var targets = document.getElementById("tipanno");
 targets.style.left=x+10;
 targets.style.top=y;
 $("#tipanno")
 .css("background-color","#AACFFC") 
 .css("display","block").text(datas[t].join('\n\n'));
              //alert( data[t].join('\n\n') );
            }
            function hideTip(){
            $("#tipanno").css("display","none");
           
            }
            (function(el, eleContainer) {
                eleContainer = eleContainer || document;
                var txt;
                var funGetSelectTxt = function() {
                    var txt = '';
                    if(document.selection) {
                        txt = document.selection.createRange().text;    // IE
                    } else {
                        txt = document.getSelection();
                    }
                    return txt.toString();
                };
                eleContainer.onmouseup = function(e) {
                    e = e || window.event;
                    txt = funGetSelectTxt();
                    var left = e.clientX - 10;
                    var top = e.clientY - 50;
                    if (txt) {
                        el.styl