接手前人的代码,首先 要新加一个日期选择功能!
找了可以复用的代码,单独测试没问题放到前人的系统里就有问题了经过用 alert()测试。问题出在这里,首先,这个日期框用到这样两个函数确定坐标,function getTop(obj) //È¡µÃY
{
var h=0;
h = obj.offsetTop;if(obj.tagName != "BODY")
h += getTop(obj.offsetParent);
return h;
}function getLeft(obj) //È¡µÃX
{
/*
if(obj.offsetParent!=null){
       alert("now is"+obj.tagName + "parent with id" + obj.offsetParent.tagName + obj.offsetParent.id);
       obj=obj.offsetParent;
       alert(obj.tagName);
}*/var h=0;
h = obj.offsetLeft;if(obj.tagName != "BODY")
 
h += getLeft(obj.offsetParent);  
return h;
}
//我理解的是用当前控件的位置不断获取父元素知道BODY放在前人的系统里有什么问题呢!!就是从<input>获取到<div>后直接获取到<HTML>了。没有获取BODY
而我查了,至少也是可以获取BODY的
哪位能给解释一下

解决方案 »

  1.   

    body是一个object的tagname
    你那前人系统里面有这tagname么?
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>index</title>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <style>
    <!--
    .nav01 {color:#000000;font-family:'Arial';}
    .nav01 a:link {font-size: 12px;color: #000000;text-decoration: none;}
    .nav01 a:visited {font-size: 12px;color:#000000;text-decoration: none;}
    .nav01 a:hover {font-size: 12px;color: #000000;text-decoration: underline;}
    .content {
    margin-left: 0px;
    margin-top: 10px;
    border: solid #b9c1d0 1px;
    background: #e1e5ec;
    width:800px;
    font-size: 12px;
    color: #4e4e4e;
    }
    .contentTop {
    margin-left: 0px;
    margin-top: 22px;
    border: solid #b9c1d0 1px;
    background: #e1e5ec;
    width:800px;
    height:47px;
    font-size: 12px;
    color: #4e4e4e;
    }
    .contentTable {
    width: 800px;
    height: 100%;
    border: 0px;
    bordercolor: red;
    cellpadding: 0;
    cellspacing: 0;
    align:left;
    }
    -->
    </style>
    </head> <script type="text/javascript" src="js/RefreshView.js"></script>
    <script type="text/javascript" src="js/tooltip.js"></script>
    <script type="text/javascript" src="js/button.js"></script>
    <script type="text/javascript" src="js/cal.js"></script>
    <script type="text/javascript" src="js/validate.js"></script>
    <script type="text/javascript" src="js/calTime.js"></script> <script language="JavaScript">
    <!--
    //单选radio改变的时候,改变相应的选择条件
    function changeDiv(){
    var radioGroup = document.queryForm.timeType;
    var div0 = document.getElementById("timePointDiv");
    var div1 = document.getElementById("timeSegmentDiv");
    var div2 = document.getElementById("timePhaseDiv");
     
    if(radioGroup[0].checked == true){
    div0.style.visibility = "visible";
    div1.style.visibility = "hidden";
    div2.style.visibility = "hidden";
    }
    else if(radioGroup[1].checked == true){
    div0.style.visibility = "hidden";
    div1.style.visibility = "visible";
    div2.style.visibility = "hidden";
    }
    else{
    div0.style.visibility = "hidden";
    div1.style.visibility = "hidden";
    div2.style.visibility = "visible";
    }
    }
    --></script> <body>
    <div id="logo" style="margin-left:0px;">
    <img src="images/newFace/logo3.gif">
    </div>

    <form name="queryForm" id="queryForm" method="POST">

    <div class
    </div>

    <input type="hidden" name="type" id="type" value="1" />
    <input type="hidden" name="ParamSelectedName" id="ParamSelectedName" />
    <input type="hidden" name="ParamSelectedNum" id="ParamSelectedNum" />
    <div class。 </div>
    <div class="content" id="timeBlock">
    <table width="800px" height="100%" border="0" bordercolor="red"
    cellpadding="0" cellspacing="0" align="left">
    <tr>
    <td width="20%" height="40px" align="right">
    <LI>
    时间类型 :
    </td>
    <td>
    <input name="timeType" type="radio" checked="checked" value="1"
    onclick="changeDiv()">

    <input name="timeType" type="radio" value="2"
    onclick="changeDiv()">

    <input name="timeType" type="radio" value="3"
    onclick="changeDiv()">
    信息
    </td>
    </tr>

    <tr>
    <td colspan="2" height="40px" valign="top">&nbsp;
    <div id="timePointDiv" style="position:absolute; margin-left:93px; margin-top:5px;visibility:visible">

    <input type="text" name="timePoint" id="TimePoint"
    maxlength="19" onFocus="javascript:vDateType='2'"
    onKeyUp="DateFormat(this,this.value,event,false,'2')"
    onBlur="DateFormat(this,this.value,event,true,'2')"><img src="img/bdbs/calBtn.gif" onclick="showDateTimeBar(this.previousSibling, '', 'y-m-d 08:00:00', 'test', 'hello world')"></img>
    &nbsp;(yyyy-MM-dd HH:mm:ss)     ////主要是这里点击image的时候只能获取到input的一级,见后面说明

    </div> <div id="timeSegmentDiv" style="position:absolute; margin-left:93px; margin-top:5px;visibility:hidden">

    <input type="text" name="timeFrom"
    maxlength="19" onFocus="javascript:vDateType='2'"
    onKeyUp="DateFormat(this,this.value,event,false,'2')"
    onBlur="DateFormat(this,this.value,event,true,'2')"><img src="img/bdbs/calBtn.gif" onclick="showDateTimeBar(this.previousSibling, '', 'y-m-d 08:00:00', 'test', 'hello world')"></img>

    <input type="text" name="timeTo"
    maxlength="19" onFocus="javascript:vDateType='2'"
    onKeyUp="DateFormat(this,this.value,event,false,'2')"
    onBlur="DateFormat(this,this.value,event,true,'2')"><img src="img/bdbs/calBtn.gif" onclick="showDateTimeBar(this.previousSibling, '', 'y-m-d 08:00:00', 'test', 'hello world')"></img>
    &nbsp;(yyyy-MM-dd HH:mm:ss)
    </div>
    <div id="timePhaseDiv" style="position:absolute; margin-left:93px; margin-top:5px;visibility:hidden">
    信息 :
    <select name="testName" id="testName" style="width:150px"
    onchange="changeCaseSelect()">
    <OPTION selected>
    请选择
    </OPTION>
    </select>

    <input name="caseTimeFrom" id="caseTimeFrom" type="text"
    readonly="true">

    <input name="caseTimeTo" id="caseTimeTo" type="text"
    readonly="true">
    </div>
    </td>
    </tr>
    </table>
    </div>
    <div class="content" id="dataBlock">
    <table 
    </table>
    </div>


    <div class="content" id="pointIDBlock">
    <table width="800px" height="100%" border="0" bordercolor="red"
    cellpadding="0" cellspacing="0"  align="middle">
    .............................
    </div> <div class="content">
    <table 。。 </table>
    </div>
    </form>
    </body>
    </html>
      

  3.   

    上面的好像格式不清楚!
    简单点应该是这样子
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>index</title>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <style>
    <!--
    .nav01 {color:#000000;font-family:'Arial';}
    .nav01 a:link {font-size: 12px;color: #000000;text-decoration: none;}
    .nav01 a:visited {font-size: 12px;color:#000000;text-decoration: none;}
    .nav01 a:hover {font-size: 12px;color: #000000;text-decoration: underline;}
    .content {
    margin-left: 0px;
    margin-top: 10px;
    border: solid #b9c1d0 1px;
    background: #e1e5ec;
    width:800px;
    font-size: 12px;
    color: #4e4e4e;
    }
    .contentTop {
    margin-left: 0px;
    margin-top: 22px;
    border: solid #b9c1d0 1px;
    background: #e1e5ec;
    width:800px;
    height:47px;
    font-size: 12px;
    color: #4e4e4e;
    }
    .contentTable {
    width: 800px;
    height: 100%;
    border: 0px;
    bordercolor: red;
    cellpadding: 0;
    cellspacing: 0;
    align:left;
    }
    -->
    </style>
    </head> <script type="text/javascript" src="js/calTime.js"></script> <script language="JavaScript"></script> <body>
    <div id="logo" style="margin-left:0px;">
    <img src="images/newFace/logo3.gif">
    </div>

    <form name="queryForm" id="queryForm" method="POST">

    <div 
    </div>

    <input type="hidden" name="type" id="type" value="1" />
    <input type="hidden" name="ParamSelectedName" id="ParamSelectedName" />
    <input type="hidden" name="ParamSelectedNum" id="ParamSelectedNum" />
    <div  </div>
    <div class="content" id="timeBlock">
    <table width="800px" height="100%" border="0" bordercolor="red"
    cellpadding="0" cellspacing="0" align="left">


    <tr>
    <td colspan="2" height="40px" valign="top">&nbsp;
    <div id="timePointDiv" style="position:absolute; margin-left:93px; margin-top:5px;visibility:visible">

    <input type="text" name="timePoint" id="TimePoint"
    maxlength="19" onFocus="javascript:vDateType='2'"
    onKeyUp="DateFormat(this,this.value,event,false,'2')"
    onBlur="DateFormat(this,this.value,event,true,'2')"><img src="img/bdbs/calBtn.gif" onclick="showDateTimeBar(this.previousSibling, '', 'y-m-d 08:00:00', 'test', 'hello world')"></img>
    &nbsp;(yyyy-MM-dd HH:mm:ss)     ////主要是这里点击image的时候只能获取到input的一级,见后面说明

    </div> <div  </div>
    <div </div>
    </td>
    </tr>
    </table>
    </div>
    <div class="content" id="dataBlock">
    <table 
    </table>
    </div>


    <div 。 </div> <div  <table 。。 </table>
    </div>
    </form>
    </body>
    </html>