// js方法 function txtMouseOver(obj) { try { var txtRange = obj.createTextRange(); var strValue = obj.value; obj.value = ""; var txtWidth = obj.scrollWidth; obj.value = strValue; var fontWidth = txtRange.boundingWidth; if (fontWidth <= txtWidth) { return; } var strHTML = ""; strHTML += "<table border=0>"; strHTML += "<tr>"; strHTML += " <td class = 'msg'><div align='center'>" + strValue + "</div></td>"; strHTML += "</tr>"; strHTML += "</table>"; oRect = obj.getBoundingClientRect(); document.all["msgBox"].innerHTML = strHTML; if (document.body.clientWidth < parseInt(oRect.left) + parseInt(txtWidth) + 2 + parseInt(fontWidth)) { document.all["msgBox"].style.posLeft = document.body.scrollLeft + oRect.left - 17 - fontWidth; } else { document.all["msgBox"].style.posLeft = document.body.scrollLeft + oRect.left + txtWidth + 2; } document.all["msgBox"].style.posTop = document.body.scrollTop + oRect.top - 5; document.all["msgBox"].style.filter="alpha(opacity=100)"; } catch(E) { } } function txtMouseOut(obj) { try { document.all["msgBox"].innerHTML = ""; } catch(E) { } } // html页面 <input style="width:290px" onMouseOver="txtMouseOver(this)" onMouseOut="txtMouseOut(this)" type="text" class="" readonly value="<%=test%>"> <div id="msgBox" style="position: absolute; left: 0px; top: 0px;"></div>
详细解决方案
显示不上弹出DIV辅助显示
热度:120 发布时间:2012-09-10 11:02:33.0
相关解决方案