首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

显示不上弹出DIV辅助显示

2012-09-10 
显示不下弹出DIV辅助显示// js方法function txtMouseOver(obj) { try {var txtRange obj.createTextRang

显示不下弹出DIV辅助显示

// 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" readonly value="<%=test%>"><div id="msgBox" style="position: absolute; left: 0px; top: 0px;"></div>

热点排行