是否你定义了div的style的宽度、高度?

解决方案 »

  1.   

    找到原因了,还是不可理喻,如果注释掉CheckBtn函数调用,就可以正常显示,请高手给个合理解释,IE的bug?还是不允许在button的disabled属性设置后再在div里写html?源代码如下:<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>模板编辑</title>
    <style>
    .{font-size:12px}
    </style>
    <script language="javascript">
    function getElementById(s)
    {
    if (document.getElementById) return(document.getElementById(s));
    if (document.all) return(document.all(s));
    try
    {
    return(eval(s));
    }
    catch(E)
    {
    return(null);
    }
    }function CheckBtn(frm, me)
    {
    var tt = me.selectedIndex;
    if (tt==-1)
    {
    frm.delbtn.disabled = true;
    frm.uppbtn.disabled = true;
    frm.lowbtn.disabled = true;
    }
    else if (me.options.length==1)
    {
    frm.delbtn.disabled = false;
    frm.uppbtn.disabled = true;
    frm.lowbtn.disabled = true;
    }
    else
    {
    frm.delbtn.disabled = false;
    frm.uppbtn.disabled = (tt==0);
    frm.lowbtn.disabled = (tt==me.options.length-1);
    }
    }function ShowDetail(frm, me)
    {
    var dst = getElementById("FrameHint");
    var tt = me.selectedIndex;
    if (tt==-1)
    {
    dst.innerHTML = '<font color="#FF0000">单击模板元素,获得元素明细</font>';
    }
    else if (me.options.length==1)
    {
    dst.innerHTML = me.options[tt].text.replace(/[&]{2}/g, '<br/>');
    }
    else
    {
    dst.innerHTML = me.options[tt].text.replace(/[&]{2}/g, '<br/>');
    }
    }function ShowFrame(frm, me)
    {
    CheckBtn(frm, me);//如果注释掉这段代码,就可以显示正常
    ShowDetail(frm, me);
    }
    </script>
    </head>
    <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" style="overflow:auto">
    <form name="a_form" action="?Handle=Add" method="post">
    <table width="790" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#000000" bgcolor="#F4FAFF" bordercolordark="#FFFFFF" bordercolorlight="#0080C0">
    <tr class="trhd">
    <td colspan="4">添加新模板(带*号的项目必须输入)</td>
    </tr>
    <tr class="trbd">
    <td width="100" class="tdbd">模板名称</td>
    <td width="690" colspan="3"><input type="text" name="Name" size="30" class="txt" /></td>
    </tr>
    <tr class="trbd">
    <td width="100" class="tdbd">选择API</td>
    <td width="300" align="center">
    <div>API</div>
    <select name="APIList" size="15" style="width:299; font-size:12px" onChange="ShowIntro(this)">
    </select>
    </td>
    <td width="90" align="center" valign="middle">
    <div style="padding-top:5px"><input type="button" value="添加&gt;&gt;" class="btn" onClick="ShowForm(this.form, 'Add')" /></div>
    <div style="padding-top:5px"><input type="button" value="追加&gt;&gt;" class="btn" onClick="ShowForm(this.form, 'Append')" /></div>
    <div style="padding-top:5px"><input type="button" value="替换&gt;&gt;" class="btn" onClick="ShowForm(this.form, 'Replace')" /></div>
    <div style="padding-top:5px"><input type="button" name="delbtn" value="删除" class="btn" onClick="MoveFrame(this.form, 'delete')" disabled="true" /></div>
    <div style="padding-top:5px"><input type="button" name="uppbtn" value="上移" class="btn" onClick="MoveFrame(this.form, 'upper')" disabled="true" /></div>
    <div style="padding-top:5px"><input type="button" name="lowbtn" value="下移" class="btn" onClick="MoveFrame(this.form, 'lower')" disabled="true" /></div>
    </td>
    <td width="300" align="center">
    <div>模板元素</div>
    <select name="FrameList" size="15" style="width:299; font-size:12px" onChange="ShowFrame(this.form, this)">
    <option value="ExportSiteLogo">ExportSiteLogo(center)&&ExportSiteLogo(center)</option>
    <option value="ExportSiteLogo">ExportSiteLogo(center)&&ExportSiteLogo(center)</option>
    </select>
    </td>
    </tr>
    <tr class="trbd">
    <td width="100" class="tdbd">模板元素明细</td>
    <td width="690" colspan="3"><div id="FrameHint" style="overflow-y:auto; width:690; height:60; color:#006600"><font color="#FF0000">单击模板元素,获得元素明细</font></div></td>
    </tr>
    <tr class="trbd">
    <td width="100" class="tdbd">API搜索</td>
    <td width="690" colspan="3"><input type="text" name="key" size="20" class="txt" />&nbsp;<input type="button" value="搜索" onClick="CallQuery(this.form, this)" class="btn" /></td>
    </tr>
    <tr class="trbd">
    <td colspan="4" align="center"><input type="button" value="确定添加" class="btn" onClick="CallAdd(this.form,this)" /></td>
    </tr>
    </table>
    </form>
    </body>
    </html>
      

  2.   

    me.options.[tt].text的值"aaa(x)&&bbb(y)"经过替换后是aaa(x)<br/>bbb(y),但是dst.innerHTML只显示aaa(x),bbb(y)却无法看到,alert(dst.innerHTML)可以看到值是aaa(x)<br/>bbb(y)
    dst.innerHTML  换成 dst.innerText试试
      

  3.   

    innerText就是显示aaa(x)<br/>bbb(y)
    但是用innerHTML就只显示aaa(x)可以随意测试,我换了好几台电脑的IE浏览器都是一样的结果,我开始以为是我的电脑有病毒了导致IE显示不正常
      

  4.   

    问题找到了,是div的overflow-y样式影响的,整个过程可以总结了,就是:
    因为设置了input.button的disabled属性,导致div.style.overflowY样式影响div.innerHTML入口失常这是IE的bug么?解决方法:
    用getElementById获取对象后,设置:
    dst.style.overflowY = "auto";
    方可使用,真是画蛇也要添个足才可以